getting datas from two mysql table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
sutejok
Forum Commoner
Posts: 37
Joined: Wed Mar 24, 2004 4:08 pm

getting datas from two mysql table

Post 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?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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'
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post 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
Post Reply