执行查询时出现以下错误消息
[2/2] DBALException: An exception occurred while executing 'SELECT DISTINCT s0_.id AS id0, s0_. AS 1 FROM shop s0_ WHERE s0_.isLocked = ? ORDER BY s0_.owner_id DESC LIMIT 20 OFFSET 0' with params [0]:
SQLSTATE[42000]: Syntax error or access violation: 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 'AS 1 FROM shop s0_ WHERE s0_.isLocked = 0 ORDER BY s0_.owner_' at line 1 +
[1/2] PDOException: SQLSTATE[42000]: Syntax error or access violation: 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 'AS 1 FROM shop s0_ WHERE s0_.isLocked = 0 ORDER BY s0_.owner_' at line 1
这应该是查询错误还是其他的?因为我的查询似乎是合法的。
答案 0 :(得分:1)
SELECT DISTINCT s0_.id AS id0, s0_. AS 1
应该是查询错误。您正在从表s0_中选择唯一ID,并且该字段没有相同表的名称,但字段不能没有名称。
您应该添加一个字段名,如下所示:
SELECT DISTINCT s0_.id AS id0, s0_.FIELDNAME AS `1`
答案 1 :(得分:0)
SELECT DISTINCT s0_.id AS id0, s0_. AS `1`
在``
中包装1上面评论中缺少的字段名称......