Marshall Mathews
Marshall Mathews

Reputation: 357

phpMyadmin returns 0 rows in sql query

This is my query

SELECT * from status_votes where vote = 'like' and status_id = 1 and item_poster = 'LUcase'

It returns 0 rows, but when I view the table there are rows which match my query phpmyadmin displaying the row

Please let me know where I am going wrong...

Upvotes: 1

Views: 1436

Answers (3)

Desolator
Desolator

Reputation: 22759

Try the following query:

SELECT * FROM `status_votes`
 WHERE `vote` = 'like'
   AND `status_id` = '1'
   AND `item_poster` = 'LUcase' 

Upvotes: 0

Abhay
Abhay

Reputation: 6645

My assumption is that perhaps there are leading or trailing spaces in your data that aren't visible looking at the values in phpMyAdmin. Can you please try to edit a record in phpMyAdmin and see if it actually contain spaces.

Please try running this query:

SELECT *
FROM status_votes
WHERE TRIM(vote) = 'like'
AND status_id = 1
AND TRIM(item_poster) = 'LUcase';

If that doesn't work, can you please share your table structure?

Upvotes: 3

Derek Tomes
Derek Tomes

Reputation: 4007

Try reducing your query to see which WHERE clause is causing problems:

Try these ONE line at a time:

SELECT * from status_votes where vote = 'like' and status_id = 1 and item_poster = 'LUcase'
SELECT * from status_votes where vote = 'like' and status_id = 1 and item_poster = 'Lucase'
SELECT * from status_votes where vote = 'like' and item_poster = 'LUcase'
SELECT * from status_votes where status_id = 1 and item_poster = 'LUcase'
SELECT * from status_votes where vote = 'like' 
SELECT * from status_votes where status_id = 1 
SELECT * from status_votes where item_poster = 'LUcase'
SELECT * from status_votes 

It shouldn't be hard to isolate the problem...

Upvotes: 3

Related Questions