我有以下MYSQL语法,但是当我运行它时,我错误地检查MYSQL手册以获得正确的语法。
MYSQL查询是:
SELECT `listings`.sid FROM listings
LEFT JOIN `listings_properties` `lp` ON `lp`.`object_sid` = `listings`.`sid` AND `lp`.`id` = \'ClosingDate\'
WHERE (expiration_date < NOW() OR `lp`.`value` <= NOW()) AND active = 1
答案 0 :(得分:1)
尝试删除'\'ClosingDate \'上的两个反斜杠()来:
SELECT `listings`.sid FROM listings
LEFT JOIN `listings_properties` `lp`
ON `lp`.`object_sid` = `listings`.`sid`
AND `lp`.`id` = 'ClosingDate'
WHERE (expiration_date < NOW()
OR `lp`.`value` <= NOW()) AND active = 1
答案 1 :(得分:1)
SELECT a.`sid` FROM `listings` a LEFT JOIN `listings_properties` b
ON (b.`object_sid` = a.`sid` AND b.`id` = 'ClosingDate')
WHERE (a.`expiration_date` < NOW() OR b.`value` <= NOW()) AND a.`active` = 1
无需逃避'
答案 2 :(得分:1)
这是错误
LEFT JOIN `listings_properties` `lp` ON `lp`.`object_sid` = `listings`.`sid` AND `lp`.`id` = \'ClosingDate\'
应该是
LEFT JOIN `listings_properties` `lp` ON `lp`.`object_sid` = `listings`.`sid` AND `lp`.`id` = 'ClosingDate'
和整个查询
SELECT a.`sid` FROM `listings` a LEFT JOIN `listings_properties` b
ON (b.`object_sid` = a.`sid` AND b.`id` = 'ClosingDate')
WHERE (a.`expiration_date` < NOW() OR b.`value` <= NOW()) AND a.`active` = 1