473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1556
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

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

Similar topics

5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
6
by: Michael | last post by:
I have two tables with a 1-many relationship. I want to write a select statement that looks in the table w/many records and compares it to the records in the primary table to see if there are any...
2
by: Wenin | last post by:
I have four total tables. Table One (Documents)- List of Documents. Each record has two fields related to this issue. First field (Document_ID) is the ID of the document, second field is the...
4
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT: declare @IDate smalldatetime select @IDate=col001...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
6
by: Bob Stearns | last post by:
I am getting duplicate rows back from a select distinct statement of the form: SELECT DISTINCT 'jhough', '000111', t0.bhid FROM (SELECT lots of good stuff) t0 LEFT OUTER JOIN another_table ...
1
by: zafm86 | last post by:
Hi everyone! I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore. I'm working with an AS400 and I mhave to do an...
3
by: sangam56 | last post by:
Hello!I am using following sql statement: SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE Permissions.RoleID=(SELECT Roles.RoleID...
0
by: cmrhema | last post by:
Hi, I have two controls one html select control and one asp.net dropdownlist control. In html select control i have three maps loaded. It is loaded in the following manner. <SELECT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.