Page 1 of 1

getting datas from two mysql table

Posted: Thu Nov 25, 2004 10:05 am
by sutejok
Hi, i have 2 mysql tables and i want to get datas from both of them.

my tables has both name and date in them. I want to get the data from both tables, sorted by the date, at one call. how do i do this?

Posted: Fri Nov 26, 2004 6:12 pm
by hawleyjr
It will be easier to help you if you show your table layout. Or example of what you've tried. Without knowing that info. try this...

Code: Select all

table 1
field_name
field_date

table 2
field_name
field_date

select a.field_date,b.field_date from table_1 as a LEFT JOIN table_2 as b on a.field_name=b.field_name where a.field_name='whatever'

Posted: Fri Nov 26, 2004 6:37 pm
by dreamline
Here's an example:
Table 1: Users -> Key = Name
Table 2: Info -> Key = Name

Select * from users usr, info inf where usr.name = inf.name and <your other conditions here and being the seperator of your conditions>

:D