Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有三张表
帖子表
id username 1 ahmed
用户表
id title 1 test post
post_users
user_id post_id 1 1
post_users(有两个字段 user_id 和 post_id)多对多
当我想发送帖子 id=1 时,我想从用户表中选择在 post_users 表中没有一行的用户(在一个查询中)。如何?
我认为您正在寻找的是这些方面的东西。内部联接:
SELECT DISTINCT USERS.ID FROM USERS INNER JOIN POST_USERS ON USERS.ID=POST_USERS.ID WHERE POST_USERS.POST_ID <> your_input_value
我做了一些假设,如果这不起作用,请提供更多详细信息。