我有3個興趣列:RateName
和URL
是varchars,MaxNum
是INT。 當我嘗試執行下面的命令,它失敗:問題與`AND`邏輯運算符mySQL
SELECT * FROM `table1` WHERE `RateName` LIKE '%$customerType%'" AND `URL` IS NOT NULL AND `MaxNum` = 2
錯誤是:#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 '" AND URL IS NOT NULL AND MaxNumOfTiers = 2' at line 1
我試圖查詢分開,下面的代碼工作正常:
SELECT * FROM `table1` WHERE `RateName` LIKE '%$customerType%'"
然而當我添加額外的AND
條件時,我收到錯誤。