Page 1 of 1
[SOLVED] Correct syntax for sql query
Posted: Tue Mar 15, 2005 8:56 pm
by Jim_Bo
Hi,
Whats to correct way to do the following:
Code: Select all
$sql = "SELECT * FROM users WHERE status = 'Active' AND 'Barely Active' AND 'Inactive' AND user_level = '2' AND '3'";
Thanks
Posted: Tue Mar 15, 2005 9:03 pm
by John Cartwright
Moved to Database.
Posted: Tue Mar 15, 2005 9:34 pm
by feyd
mind explaining the logic you are going after?
Posted: Tue Mar 15, 2005 9:48 pm
by Jim_Bo
Hi,
Yer I have 2 fields that hold predefined info that I need to filter down ..
ie:
field "status" which holds one of the following values ...
Active, Barely Active, Inactive, Resigned
Field "user_level" which holds one of the following values ...
1, 2, 3, 4, 5
I am trying to display users that match the following ...
Active, Barely Active, Inactive
2,3,4,5
Not displaying any users matching "user_level" 1 or "status" Resigned
Also counting the records that match the above values ..
Thanks
Posted: Tue Mar 15, 2005 9:55 pm
by feyd
Code: Select all
SELECT * FROM `users` WHERE `status` IN ('Active','Barely Active', 'Inactive) AND `user_level` IN ('2','3')
I believe.
Posted: Tue Mar 15, 2005 10:14 pm
by Jim_Bo
Hi feyd,
That works great ..
Thanks ..
Jim_bo