开发者

MySQL join query - Not unique table/alias

开发者 https://www.devze.com 2023-04-13 02:23 出处:网络
What could be wrong with this one? I am getting Error #1066 - Not unique table/alias: \'v\' SELECT v.newsid AS identifier, j.createdate AS DATE, j.newstext AS TEXT, j.uuid AS user, j.flags AS fcount,

What could be wrong with this one? I am getting Error #1066 - Not unique table/alias: '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 )   
L开发者_C百科IMIT 20


you cannot use the same table alias multiple times. You are associated v with votes and table news.

Change your query and alias references to something like

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


I think the news table's alias should be "j". You have used "j.newsid = v.newsid" in join statement

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号