Finding a value in multiple tables
I need to find a userid across several different tables. What is the best way to do this? For example I have three tables TableA TableB TableC They all have a field id I want to find the value 123 in the field id in any one of these tables. Thanks, David Ruggles CCNA MCSE (NT) CNA A+ Network EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Finding a value in multiple tables
On Tue, July 31, 2007 8:52, David Ruggles said: I need to find a userid across several different tables. What is the best way to do this? For example I have three tables TableA TableB TableC They all have a field id I want to find the value 123 in the field id in any one of these tables. Thanks, David Ruggles CCNA MCSE (NT) CNA A+ Network Engineer Safe Data, Inc. (910) 285-7200[EMAIL PROTECTED] Possibly use a union? I think more details would help. --- William R. Mussatto, Senior Systems Engineer http://www.csz.com Ph. 909-920-9154 ext. 27 FAX. 909-608-7061 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Finding a value in multiple tables
I want to find the value 123 in the field id in any one of these tables. SELECT id FROM TableA WHERE id = 123 UNION SELECT id FROM TableB WHERE id = 123 UNION SELECT id FROM TableC WHERE id = 123 Please note that UNION requires that the same number (and type?) of fields be selected from each table. thnx, Chris -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Finding a value in multiple tables
It might have been a dumb question, but I really wasn't sure where to start. Union does exactly what I need! Thanks a bunch. Thanks, David Ruggles CCNA MCSE (NT) CNA A+ Network EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -Original Message- From: Wm Mussatto [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 31, 2007 11:56 AM To: mysql@lists.mysql.com Subject: Re: Finding a value in multiple tables On Tue, July 31, 2007 8:52, David Ruggles said: I need to find a userid across several different tables. What is the best way to do this? For example I have three tables TableA TableB TableC They all have a field id I want to find the value 123 in the field id in any one of these tables. Thanks, David Ruggles CCNA MCSE (NT) CNA A+ Network Engineer Safe Data, Inc. (910) 285-7200[EMAIL PROTECTED] Possibly use a union? I think more details would help. --- William R. Mussatto, Senior Systems Engineer http://www.csz.com Ph. 909-920-9154 ext. 27 FAX. 909-608-7061 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]