Reputation: 63
I know this is going to be answered in all of two seconds, but I can't find it anywhere online. I need to omit two things from my query...
I don't want their information showing up if they've set their display to "no" or they haven't been verified (I put in a "yes" when they've been verified")
As you can see, I only included those with display='yes'. How do I get the other part?
$query = "SELECT * FROM $table WHERE display='yes'"
Do I just do this?
SELECT * FROM $table WHERE display='yes' AND verified='yes'"
Upvotes: 0
Views: 3002
Reputation: 63
Thanks for the comments everyone. This is what I ended up going with:
$query = "SELECT * FROM $table WHERE display='yes' AND verified='yes'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
Worked like a charm! Excluding those who said "yes" to "please display my info" and "yes" to those that had been verified. Sorry for the confusion in my initial question!
Upvotes: 1
Reputation: 28837
WHERE display<>'no' AND verified IS NOT NULL
verified = NULL will never match, as by definition the result is NULL which is in effect a nomatch. Testing NULL for equality really ought to be a syntax error.
Upvotes: 4
Reputation: 52
Try it out with 'LIKE':
SELECT * FROM $TABLE WHERE DISPLAY LIKE 'yes' AND VERIFIED LIKE 'yes'
Upvotes: -1
Reputation: 39485
Yes, you should use the AND
keyword in the WHERE
clause. You should also give it a try, and let us know if there are any issues.
Upvotes: 0