将SQL查询格式化为正确的JOIN

时间:2017-02-15 13:26:10

标签: mysql join

尝试转换以下查询以使用JOIN而不成功:

select * from usrdata
   where recordid=any(select usrdataid from usrclix
      where clidataid=any(select recordid from clidata
         where subdataid='dd87cb0c-e571-11e6-b2b8-d4ae52cc00a8'));

我尝试过LEFT JOINS,JOINS等,但我无法获得正确的结果集。有人可以帮我正确地使用JOINS来解决这个问题。谢谢。

1 个答案:

答案 0 :(得分:0)

检查这个

SELECT * 
FROM userdata u
LEFT JOIN usrclix uc ON u.recordid = uc.userdataid
LEFT JOIN (SELECT recordid FROM clidata WHERE subdataid = 'dd87cb0c-e571-11e6-b2b8-d4ae52cc00a8') as cd ON c.clidataid = cd.recordid;