这是我的查询
SELECT * from status_votes where vote = 'like' and status_id = 1 and item_poster = 'LUcase'
它返回0行,但是当我查看表时,会有与我的查询匹配的行
请让我知道我哪里出错...
答案 0 :(得分:3)
尝试减少查询以查看哪个WHERE子句导致问题:
一次尝试这一行:
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
解决问题应该不难......
答案 1 :(得分:3)
我的假设是,数据中可能存在前导或尾随空格,看不到phpMyAdmin中的值。你可以尝试在phpMyAdmin中编辑一条记录,看看它是否真的包含空格。
请尝试运行此查询:
SELECT *
FROM status_votes
WHERE TRIM(vote) = 'like'
AND status_id = 1
AND TRIM(item_poster) = 'LUcase';
如果这不起作用,请您分享一下表结构吗?
答案 2 :(得分:0)
尝试以下查询:
SELECT * FROM `status_votes`
WHERE `vote` = 'like'
AND `status_id` = '1'
AND `item_poster` = 'LUcase'