Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql SQL查询4路连接以查找不存在的用户_Mysql_Sql - Fatal编程技术网

Mysql SQL查询4路连接以查找不存在的用户

Mysql SQL查询4路连接以查找不存在的用户,mysql,sql,Mysql,Sql,我有四张桌子。。。用户、朋友、文章和文章共享(如书面形式) 用户只需邀请他们阅读就可以共享他们创建的文章。我试图找到的是文章创建者id 63的朋友列表,他们还没有被邀请分享文章id 34 因此,表用户: user_id - name 10 Dan 11 Doug 12 Chad 13 Ben 63 John 餐桌朋友 user_id - friends_id 63 10 63 11 6

我有四张桌子。。。用户、朋友、文章和文章共享(如书面形式)

用户只需邀请他们阅读就可以共享他们创建的文章。我试图找到的是文章创建者id 63的朋友列表,他们还没有被邀请分享文章id 34

因此,表用户:

user_id - name 
10         Dan
11         Doug
12         Chad
13         Ben
63         John
餐桌朋友

user_id - friends_id
63        10
63        11
63        12
63        13
桌上物品

article_id - user_id_creator
34           63
表1第11条股份

article_id - user_id_sharedWith
34           10
34           11
从上面的数据中,我想返回id为12和13的用户。。查德和本

以下是我正在尝试的:

select u.name, u.user_id, u.live_prof_pic from users u
join friends f on f.user_id = u.user_id 
join articles a on a.user_id_creator = f.friends_id
join article_shares as on as.articl_id <> a.article_id
where ((f.friends = '63') && (a.article_id = '34'))
它只是返回0

有什么想法吗?

试试看

SELECT  c.friends_ID
FROM    articles a
        INNER JOIN users b
            ON a.user_Id_creator = b.user_ID
        INNER JOIN friends c
            ON b.user_ID = c.user_ID
        LEFT JOIN article_shares d
            a.article_ID = d.article_ID
WHERE   b.user_ID = 63 AND
        a.article_ID = 34 AND
        d.article_ID IS NULL

你能提供虚拟记录吗?也谢谢,你想要什么记录?还有这些列。我想返回没有共享文章的朋友的用户数据,即用户12和13,所以为他们返回u.name、u.user、u.live\u prof_pic@DarrenSweeney这个怎么样?明亮的我以为我已经把这个连接的东西整理好了,但这似乎是一个完整的下一个层次!非常感谢你的时间和帮助,非常感谢约翰。