MySQL连接查询 - 不是唯一的表/别名

时间:2011-10-12 19:13:58

标签: mysql

这个可能有什么问题?我收到错误#1066 - 不是唯一的表/别名:'v'

SELECT v.newsid AS identifier, j.createdate AS DATE, j.newstext AS TEXT, j.uuid AS user, j.flags AS fcount, j.votes AS vcount, j.authornick AS nick 
FROM votes v 
INNER JOIN news v ON j.newsid = v.newsid GROUP BY v.newsid ORDER BY COUNT( v.newsid )   
LIMIT 20

2 个答案:

答案 0 :(得分:4)

您不能多次使用相同的表别名。您已将vvotes和表格news相关联。

将您的查询和别名引用更改为

SELECT .....
FROM votes v 
INNER JOIN news n ON ....
               ^^^ <=== Change this to something else

答案 1 :(得分:2)

我认为新闻表的别名应为“j”。您在连接语句

中使用了“j.newsid = v.newsid”