此左连接查询工作正常:
SELECT * FROM `Articles`
LEFT JOIN `uploaders` ON
uploaders.username=Articles.Poster
ORDER BY `DATE` ASC LIMIT 5;
但是当在第一个表中添加“where”时
SELECT * FROM `Articles` WHERE `Content` OR `Title` LIKE '%somthing'
LEFT JOIN `uploaders` ON
uploaders.username=Articles.Poster
ORDER BY `DATE` ASC LIMIT 5;
我得到语法错误。
我试着说出第一个结果,但还是同样的错误
一:
SELECT * FROM `Articles` WHERE `Content` OR `Title` LIKE '%somthing' AS art
LEFT JOIN `uploaders` ON
uploaders.username=art.Poster
ORDER BY `DATE` ASC LIMIT 5;
2:
(SELECT * FROM `Articles` WHERE `Content` OR `Title` LIKE '%somthing')Art
LEFT JOIN `uploaders` ON
uploaders.username=Art.Poster
ORDER BY `DATE` ASC LIMIT 5;
我做错什么了?如果不是这样我还能怎么做?
最佳答案
连接后的位置:
SELECT * FROM `Articles`
LEFT JOIN `uploaders` ON
uploaders.username=Articles.Poster
WHERE `Content` LIKE '%somthing' OR `Title` LIKE '%somthing'
ORDER BY `DATE` ASC LIMIT 5;