mysql - mysql通过交叉连接加入三个表错误
问题描述
我想获得一些不在用户名评级表中的详细信息,我进行了交叉连接查询。但它向我显示语法错误
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
我想在用户表中的用户名不在评级表中的应用程序中获取用户详细信息。我怎样才能解决这个问题?
解决方案
我认为您需要这样的查询:
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;
推荐阅读
- java - 单击按钮时依次显示每个数组列表元素
- csv - 比较两个不同长度的 CSV 文件
- mongodb - 如何使用pymongo获取数组所有对象中特定元素的总和
- mongodb - Spring Web、Kotlin、Gradle、IntelliJ -> MongoRepository “未解决的参考:保存”问题
- azure-devops - 要求通过 Azure Pipeline 更新 Azure Function
- r - 结构时间函数
- tcp - 使用 TCP 滑动窗口的一个理论问题:如何处理不匹配的窗口大小?
- javascript - 在 Ninja Forms 中强制要求两个表单字段中的至少一个
- r - R - 我如何最有效地滞后/领先 data.table 中的多个列多个时期
- javascript - 为什么我的 javascript 代码没有从 html 更新任何文本?