>-----Original Message----- >From: Lamp Lists [mailto:lamp.li...@yahoo.com] >Sent: Wednesday, December 17, 2008 2:57 PM >To: mysql@lists.mysql.com >Subject: need help with query...
...snip... >I have let say 3 tables people, organization, addresses. and they are >linked to each other with column person_id. >to select person by specified person_id it's not big deal, really >simple. though, I wonder how can I select records from these three >tables but somehow marked which table it belongs? > [JS] Admittedly I'm not really good with this stuff, but I think this works: SELECT 'table1' AS tablename, person_id FROM table1 WHERE person_id = 123 UNION SELECT 'table2', person_id FROM table2 WHERE person_id = 123 UNION SELECT 'table3', person_id FROM table2 WHERE person_id = 123; That would give you all of the tables in which a particular person_id is found. I don't know if this suits your needs. Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com www.giiexpress.com www.etudes-marche.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org