也许一双新鲜的眼睛可以帮助我。我认为这个错误对应于AND OR语句,但我切换了一些东西,仍然收到了同样的错误。有人看到以下陈述有什么问题吗?谢谢。查询在没有like子句的情况下工作正常。
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 '%castillo%OR p.city LIKE%castillo%OR p.country LIKE附近 %castillo%)GROUP BY ima'在第1行
SELECT p.id,p.name,p.city,p.country,images.name as image, MIN(images.position)作为位置FROM属性为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
答案 0 :(得分: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