Saturday, 17 August 2013

Simple select query returning empty result set?

Simple select query returning empty result set?

I can't explain this. What fundamental thing am I overlooking which is
causing this not to work? I have a simple table with only one entry (for
testing purposes) at the moment:
TABLE votes
vote_id | user_id | image_id | vote_type
----------------------------------------
43 | 8 | 5 | 1
Where vote_id is a primary key, user_id & image_id are foreign keys, and
vote_type is a boolean
This ridiculously simple select query with 2 WHERE clauses won't even
return the one entry in the table:
SELECT * FROM `votes` WHERE 'user_id' = 8 AND 'image_id' = 5;
Even 1 WHERE clause doesn't return anything:
SELECT * FROM `votes` WHERE 'vote_type' = 1;
Yet, a SELECT with no conditions does return the 1 result:
SELECT * FROM `votes`;
Note, I don't get any errors, I just get told that "MySQL returned an
empty result set". What's going on here?

No comments:

Post a Comment