List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:December 17 2008 8:30pm
Subject:RE: need help with query...
View as plain text  

>-----Original Message-----
>From: Lamp Lists [mailto:lamp.lists@stripped]
>Sent: Wednesday, December 17, 2008 2:57 PM
>To: mysql@stripped
>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




Thread
MySQL 5.0.67 on SMPxufeng16 Dec
  • Re: MySQL 5.0.67 on SMPDan Nelson16 Dec
    • RE: MySQL 5.0.67 on SMPxufeng17 Dec
  • Re: MySQL 5.0.67 on SMPewen fortune16 Dec
  • need help with query...Lamp Lists17 Dec
    • Re: need help with query...Jason Pruim17 Dec
      • Re: need help with query...Andy Shellam17 Dec
        • RE: need help with query...Jerry Schwartz17 Dec
          • Re: need help with query...Andy Shellam17 Dec
    • RE: need help with query...Jerry Schwartz17 Dec
  • Re: need help with query...Lamp Lists17 Dec
    • Re: need help with query...Andy Shellam17 Dec
  • Re: need help with query...Lamp Lists17 Dec
RE: MySQL 5.0.67 on SMPxufeng16 Dec
  • Re: MySQL 5.0.67 on SMPJoerg Bruehe16 Dec