Re: Get data from 5 tables
| From: | Patrick Schnegg | Date: | Thu, 06 Mar 2003 12:01:26 +0000 |
| Subject: | Re: Get data from 5 tables | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138449@lists.php.net to get a copy of this message | ||
To keep those similiar column names apart and more readable, you might want
to use AS.
SELECT table1.data AS data1, table2.data AS data2 ... FROM table1, table2
...
Of course this is optional, you can always use table1.data, table2.data
instead. Hope that answers your actual question as to how you know which
data comes from which table.
"Osman Omar" <osman@sem.my.sony.com.sg> wrote in message
news:Pine.LNX.4.44.0303061453310.11581-100000@safety...
> ok,
>
> how do I know which data come from which table?
>
>
>
> On Wed, 5 Mar 2003, olinux wrote:
>
> > SELECT * FROM table1, table2, table3, table4
> > WHERE id = 1 AND
> > table1.id=table2.id AND
> > table2.id=table3.id AND
> > table3.id=table4.id AND
> > etc.
> >
> >
> > or you can use a JOIN
> > http://www.mysql.com/doc/en/JOIN.html
> >
> >
> > --- Osman Omar <osman@sem.my.sony.com.sg> wrote:
> > > Hi,
> > >
> > > How do I query to get data from 5 tables with same
> > > id. (id=1).
> > >
> > > eg,
> > >
> > > table1
> > > id data
> > > 1 blue
> > > 2 green
> > >
> > > table2
> > > id data
> > > 1 yellow
> > > 3 green
> > >
> > > table3
> > > id data
> > > 1 black
> > > 4 white
> > >
> > > etc.
> > >
> > > thanks
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, more
> > http://taxes.yahoo.com/
> >
> >
>