Reputation: 1579
I have a mysql query that throws an error which I'm guessing is because of my judicious use of the phrase "NOT IN":
$sqlGetCountry = mysqli_query($link, "SELECT * FROM locations WHERE country='$country' AND CURTIME() > time AND '$state' NOT IN state ORDER BY time desc LIMIT 20");
$sqlNumCountry = mysqli_num_rows($sqlGetCountry);
I have a table with city, state, and country and I'm basically trying to find the queries where a given state ($state in this case, which could be Texas, Hawaii, etc.) is not in the results. I get the error:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Anybody have a clue?
Upvotes: 0
Views: 72
Reputation: 238078
You can't pass a table to in
, but you can pass a subquery:
SELECT *
FROM locations
WHERE country='$country'
AND CURTIME() > time
AND '$state' NOT IN (select state from state)
ORDER BY
time desc
LIMIT 20
Upvotes: 2