|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Gavin Towey (gtowey
ffn.com)
Date: Mon Jul 27 2009 - 15:12:10 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Should be more efficient to do something like:
SELECT Main_ID FROM Table1 WHERE Source1_Name = 'name'
UNION
SELECT Main_ID FROM 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:joao
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
T1.Source1_Name = "anything" or
T2.Source2_Name = "anything" or
T3.Source3_Name = "anything"
Not tested.
--
João Cândido de Souza Neto
SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
Fone: (0XX41) 3033-3636 - JS
www.siens.com.br
""Rytsareva, Inna (I)"" <IRytsareva
dow.com> escreveu na mensagem
news:3C9BDF0E91897443AD3C8B34CA8BDCA80218F69F
USMDLMDOWX028.dow.com...
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 Main_ID
How to make it?
Thanks, Inna
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gtowey
ffn.com
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]