mysql连接三个表交叉连接错误

hgqdbh6s  于 2021-06-18  发布在  Mysql
关注(0)|答案(2)|浏览(341)

我想用用户名获取一些不在评分表中的详细信息,并进行了交叉连接查询。但它显示了语法错误

SELECT applications.reference as "User id", applications.id
FROM applications
cross join ratings where (applications.id) NOT IN ( SELECT ratings.application_id FROM ratings )
INNER JOIN ratings ON users.id=ratings.user_id

错误显示


# 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INNER JOIN ratings ON users.id=ratings.user_id LIMIT 0, 25' at line 2

我想获得应用程序中的用户详细信息,其中不在评分表中,用户名在用户表中。我怎样才能解决这个问题?

lsmepo6l

lsmepo6l1#

选择applications.reference作为“user id”,applications.id from applications inner join ratings on users.id=ratings.user\u id交叉连接ratings where(applications.id)not in(选择ratings.application\u id from ratings)

z4iuyo4d

z4iuyo4d2#

我想你需要这样一个问题:

SELECT a.reference as "User id", a.id
  FROM applications a
 CROSS JOIN ratings r
 INNER JOIN users u ON u.id = r.user_id 
 WHERE a.id != r.application_id;

相关问题