SELECT `news_posts`.`ID` , `category`.`ID` , `news_posts`.`Title` , `news_posts`.`Author` , `news_posts`.`Time` , `news_posts`.`Cat_ID` , `news_posts`.`Tags` , `news_posts`.`imageLocation` , `news_posts`.`thumbLocation` , `category`.`name`
FROM `news`.`category`
LEFT JOIN `category`.`ID` = `news_posts`.`Cat_ID`
LIMIT 0 , 30
这是它带来的错误
1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以便在“。
Cat_ID
LIMIT 0,30'第16行附近使用正确的语法
答案 0 :(得分:3)
您缺少表名news_posts
和ON
关键字。它应该是:
...
FROM `news`.`category`
LEFT JOIN news_posts ON `category`.`ID` ...
...
像这样:
SELECT
`news_posts`.`ID` , `category`.`ID` ,
`news_posts`.`Title` , `news_posts`.`Author` ,
`news_posts`.`Time` , `news_posts`.`Cat_ID` ,
`news_posts`.`Tags` , `news_posts`.`imageLocation` ,
`news_posts`.`thumbLocation` , `category`.`name`
FROM `news`.`category`
LEFT JOIN news_posts ON `category`.`ID` = `news_posts`.`Cat_ID`
LIMIT 0 , 30