2012-06-24 49 views
0

也许一组新的眼睛可以帮助我解决这个问题。我认为这个错误对应于AND OR语句,但我切换了一些东西,仍然收到相同的错误。有人看到以下陈述有什么问题吗?谢谢。查询工作正常,没有类似的子句。MySQL sql语法错误LIKE语句和条件

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

选择p.id,p.name,p.city,p.country,images.name作为图像, MIN(images.position)作为位置FROM属性作为p,property_images 作为图像WHERE p.id = \ images .property_id AND p.is_active = 1 AND(p.name LIKE%卡斯蒂略%OR p.city LIKE%卡斯蒂略%OR p.country LIKE%卡斯蒂略%)GROUP BY images.property_id

+0

要休息,您需要:D – Sebas

回答

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 
+0

报价是ty,只要我能够接受,我会尽快接受。 – dm03514