469,647 Members | 1,682 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

select from three tables and WHERE statement

16
I have a feeling that this is an easy question. However I'm a newbee and don't have any idea how to do this.
I have three tables that stores my users information. Each user has a unique ID that is same in all three tables and is the way that connects the data for the user.
Table1 has userid and useremail
Table2 has userid and status
Table3 has userid and name, email, phone number and .....

user status can be Active, Pending, Expired or Canceled.

I need to have a page that shows only Active users with their details on each row.

I know I need to use SELECT and WHERE, but I can do that only for table2. When I try to add other tables to it everything gets missed up.

Thanks
Dec 20 '07 #1
1 1387
stepterr
157 100+
You'll want to use JOIN between the tables. Something like this should work for you.

[PHP] Select
TABLE1.*, TABLE2.*, TABLE3.*
From
TABLE1
Inner Join TABLE2 On
TABLE1.ID = TABLE2.ID
Inner Join TABLE3 On
TABLE2.ID = TABLE3.ID [/PHP]
Dec 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by jayson_13 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.