-2

次の 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
4

3 に答える 3

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
于 2012-09-30T08:26:14.873 に答える
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

逃げる必要はない'

于 2012-09-30T08:26:26.773 に答える
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
于 2012-09-30T08:27:11.890 に答える