2016-05-06 57 views
0

我正在嘗試在我的網站上編寫一個搜索欄,當我添加WHERE時,我會遇到錯誤。SQL SELECT INNER JOIN WHERE偏移量

$SELECT * 
FROM articles 
INNER JOIN fournisseur ON fournisseur.fournisseur_id = articles._fournisseur_id 
ORDER BY ".$order." LIMIT ".$limit." OFFSET ".$debut." 
WHERE article_designation LIKE ".$recherche." 

這裏是錯誤消息:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE article_designation LIKE aspirateur' at line 1' in

請求是完全沒有WHERE工作。查詢有什麼問題?

+0

限制之前去那裏,通常訂購 – arcee123

+1

正確的順序是'SELECT ... FROM ... INNER JOIN ... WHERE ... ORDER BY ... LIMIT' – Siyual

+0

...並且您只需在關鍵字WHERE之前需要一個空格 – Webomatik

回答

0

你需要你的WHERE子句來之前ORDER BYLIMIT

+0

謝謝你的幫助 :) – BigSnowfr