我有两个表我想查询:MySQL的左连接错误#1064
- tbl_sermons
- tbl_sermons系列
我已经试过了MySQL查询几种不同的方式,但它不断有类似的东西回来:
"#1064 - 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 ''tbl_sermons-series' ON tbl_sermons.series_sermon = 'tbl_sermons-series.id_seri' at line 3"
下面是该查询:
SELECT tbl_sermons.title_sermon, tbl_sermons.slug_sermon, tbl_sermons.date_sermon, 'tbl_sermons-series.name_series'
FROM tbl_sermons
LEFT JOIN 'tbl_sermons-series'
ON tbl_sermons.series_sermon = 'tbl_sermons-series.id_series';
我确定我在做一些愚蠢的事情......有人能成为我的第二套眼睛吗?
===
所以我用在一个点上反引号,但是这是之前引发错误。我回去用每个给定的(感谢)的建议反引号,现在我收到以下错误:
1054 - Unknown column 'tbl_sermons-series.name_series' in 'field list'
我看tbl_sermons系列表,它的存在一样的领域,我请求(name_series) 。如果我删除了name_series的请求,并且只是在LEFT JOIN结尾处的tbl_sermons-series.id_series中(在ON的等号右边),它将引发与tbl_sermons.id_series相同的错误!
以下是tbl_sermons(第一)和tbl_sermons系列(第二)的片剂定义:
当前失败的确切的代码是:
SELECT tbl_sermons.title_sermon, tbl_sermons.slug_sermon, tbl_sermons.date_sermon, `tbl_sermons-series`.`name_series`
FROM tbl_sermons
LEFT JOIN `tbl_sermons-series`
ON tbl_sermons.series_sermon = `tbl_sermons-series`.`id_series`;
避开摆脱单引号''tbl_sermons-series.id_series'' – mseifert
是的,你是对的,你正在做一些愚蠢的事,就是用单引号。 mysql将它视为字符串而不是某个变量或关键字。 – Mannu
谢谢,我最初使用反引号,但是当它没有工作尝试单引号时,现在我已经回到反引号,并且正在得到另一个错误... – davemackey