RE: [PHP-DB] Selecting data from multiple tables
by Jack van Zanen other posts by this author
Sep 27 2003 11:00PM messages near this date
[PHP-DB] Selecting data from multiple tables
|
[PHP-DB] If in a query
Hi
You did not mention your DB , but following syntax should get you on your
way
select tbl1.user_id
, tbl1.username
, tbl2.age
, tbl3.town
, tbl3.country
from tbl1
, tbl2
, tbl3
where tbl1.user_id=tbl2.user_id
and tbl1.user_id=tbl2.user_id
and tbl2.user_id=tbl3.user_id (not neccessary but sometimes better
performance)
and tbl2.age=30
and tbl3.country='UNITED KINGDOM'
Jack
-----Original Message-----
From: Awlad Hussain [mailto:awlad@[...].com]
Sent: zaterdag 27 september 2003 15:58
To: php-db@[...].net
Subject: [PHP-DB] Selecting data from multiple tables
I have three tables as shown below:
tbl1
---------------
user_id
username
password
..............
..............
tbl2
--------------
user_id
age (date)
tbl3
-----------
user_id
town
country
How can i construct sql query for example to select data from all three
tables where age is 30 and country is United Kingdom?
Many Thanks in Advance.
AH
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Awlad Hussain
Jack van Zanen
|