SELECT DISTINCT r.ID, b.idB, bi.location, type, englishName, chineseName, bedroom, specialOffer, squareMeter, pic1, d.district_name, type, marketPrice, r.decoration
FROM building b, residential r, Binfo bi, districts d
WHERE b.compGroup = ''
AND bi.language_id = '1'
AND r.buildingID <>
AND b.idB=r.buildingID
AND bi.idB = b.idB
AND d.district_id=b.dist_id
AND ptype = 'lease'
AND visibility = 1
AND activation = 1
GROUP BY ID
ORDER BY updated, bedroom, specialOffer
limit 0,15You 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 b.idB=r.buildingID
AND bi.idB = b.idB
' at line 6