在下面的代码中,我想将表c_files cf与两个圆括号(别名x)内seccond查询的结果连接起来。
SELECT f_cl_path f,cf.f_id, 'xx' as jo
FROM c_files cf
LEFT JOIN
(SELECT f_cl_path f, f_id, f_workgroup, 'yy' as jo FROM myOtherTable
WHERE f_workgroup ='1234' AND f_status<=2) x
ON x.f_id=cf.f_id
WHERE cf.f_workgroup='798190' and jo='xx';
我只想得到
jo='xx'
的元素。但这不管用。当我用jo='yy'
来尝试时,我得到了一个结果,但我需要用jo='xx'
来尝试。 最佳答案
在看到你的评论之后,也许这张图片会有帮助。
如果我没有错的话,你的情况会是这样的:
SELECT f_cl_path f,cf.f_id
FROM c_files cf
LEFT JOIN (SELECT f_cl_path f, f_id, f_workgroup FROM myOtherTable
WHERE f_workgroup ='1234' AND f_status<=2) as x
ON x.f_id=cf.f_id
WHERE cf.f_workgroup='798190' and x.f_id IS NULL
关于mysql - 仅解析Join的左侧,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21099761/