By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

select from three tables and WHERE statement

P: 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
Share this Question
Share on Google+
1 Reply


stepterr
100+
P: 157
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.