2015-11-18 213 views
0

即使所有「情況」均正確且位於數據庫中,此SQL查詢仍未顯示帖子。 查詢 - $sql = "SELECT * FROM posts WHERE like BETWEEN 5 AND 25 AND bp='0' ORDER BY id DESC LIMIT 15 ";SQL查詢不起作用

爲什麼不能正常工作?我如何解決它?

回答

2

like是一個保留字,所以你要逃避它:

SELECT * 
FROM posts 
WHERE `like` BETWEEN 5 AND 25 AND bp = '0' 
ORDER BY id DESC 
LIMIT 15 ; 
+1

,也許你可以改變你的列名喜歡?那麼你再也沒有查詢問題了 – davejal