0

也许一双新的眼睛可以帮助我解决这个问题。我认为这个错误对应于 AND OR 语句,但我换了东西,仍然收到同样的错误。有人看到以下陈述有什么问题吗?谢谢你。没有 like 子句,查询工作正常。

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '%castillo% OR p.city LIKE %castillo% OR p.country LIKE %castillo% ) GROUP BY ima' 附近使用正确的语法

选择 p.id,p.name,p.city,p.country,images.name 作为图像,MIN(images.position) 作为位置 FROM properties as p,property_images 作为图像 WHERE p.id = \images.property_id AND p .is_active = 1 AND (p.name LIKE %castillo% OR p.city LIKE %castillo% OR p.country LIKE %castillo%) GROUP BY images.property_id

4

1 回答 1

2

尝试在你的字符串文字周围加上一些引号,例如

SELECT p.id, p.name, p.city, p.country, images.name as image, MIN(images.position) as position 
FROM properties as p, property_images as images
WHERE p.id = images.property_id 
  AND is_active = 1 
  AND ( p.name LIKE '%castillo%' OR p.city LIKE '%castillo%' OR p.country LIKE '%castillo%' ) 
GROUP BY images.property_id
于 2012-06-24T22:57:28.697 回答