1

このSQLクエリが実行されない理由を誰か教えてもらえますか?

SELECT t_ads.*, t_adpics.picfile, 
FROM t_ads 
LEFT JOIN t_adpics ON t_ads.adid = t_adpics.adid AND t_adpics.isevent = '0' 
LEFT JOIN t_featured ON t_ads.adid = t_featured.adid AND t_featured.adtype = 'A' 
WHERE (a.adtitle LIKE '%findandpost%' OR a.addesc LIKE '%findandpost%') 
AND a.enabled = '1' 
AND a.verified = '1' 
AND a.expireson >= NOW() 
AND a.paid <> '0' 
AND (t_featured.adid IS NULL OR t_featured.featuredtill < NOW()) 
GROUP BY t_ads.adtitle 
ORDER BY RAND() LIMIT 0, 50

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM t_ads LEFT JOIN t_adpics ON t_ads.adid = t_a' at line 4

4

3 に答える 3

1

t_featured.adtype = 'A' AND 条件を WHERE 句に入れ、キーワードの,前に削除する必要がありますFROM

SELECT t_ads.*, t_adpics.picfile
FROM t_ads LEFT JOIN t_adpics ON t_ads.adid = t_adpics.adid 
LEFT JOIN t_featured ON t_ads.adid = t_featured.adid 
WHERE (a.adtitle LIKE '%findandpost%' OR a.addesc LIKE '%findandpost%')
        AND a.enabled = '1' AND a.verified = '1' 
        AND a.expireson >= NOW() AND a.paid <> '0' 
        AND (t_featured.adid IS NULL OR t_featured.featuredtill < NOW())
        AND t_featured.adtype = 'A'
        AND t_adpics.isevent = '0'
GROUP BY t_ads.adtitle ORDER BY RAND() LIMIT 0, 50
于 2013-04-18T12:53:35.113 に答える