Hello.
I have 4 tables:
MainTable (Main_ID, Main_Name)
Table1 (Source1_ID, Source1_Name, Main_ID)
Table2 (Source2_ID, Source2_Name, Main_ID)
Table3 (Source3_ID, Source3_Name, Main_ID)
And a search box.
A user can type any names from Source1_Name or Source2_Name or
Source3_Name.
I need to get
select
*
from
MainTable MT
left join Table1 T1 on MT.Main_ID = T1.MainID
left join Table2 T2 on MT.Main_ID = T2.MainID
left join Table3 T3 on MT.Main_ID = T3.MainID
where
T1.Source1_Name = anything or
T2.Source2_Name = anything or
T3.Source3_Name = anything
Not tested.
--
...@consultorweb.cnt.br]
Sent: Monday, July 27, 2009 1:09 PM
To: mysql@lists.mysql.com
Subject: Re: SELECT query question
select
*
from
MainTable MT
left join Table1 T1 on MT.Main_ID = T1.MainID
left join Table2 T2 on MT.Main_ID = T2.MainID
left join Table3 T3 on MT.Main_ID = T3.MainID
where
Table2 WHERE Source2_Name = 'name'
UNION
SELECT Main_ID FROM Table3 WHERE Source3_Name = 'name'
-Original Message-
From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
Sent: Monday, July 27, 2009 1:09 PM
To: mysql@lists.mysql.com
Subject: Re: SELECT query question
select
I have a test results table that looks like this
student_id test_id score
1 1 90
1 1 100
1 1 80
2 1 95
2 1 85
2 1
Luis Lebron wrote:
I have a test results table that looks like this
student_id test_id score
1 1 90
1 1 100
1 1 80
2 1 95
2 1 85
2
I have a table where patient visits are logged each visit, the table is:
patientnumber,visitdate,location
I need to select and count the number of records that have 2 or more entries
with the same patientnumber
in sql-english:
select count(*) where there are two or more records with the same