从成员列表中排除用户列表(联盟?)
非常感谢您对以下问题的指导。
我试图通过消除其他他/她的列表中已存在的用户来显示用户列表(向用户)。
例如,我想向某个用户显示我的所有网站用户,减去他的阻止列表。
我相信我需要使用 UNION 运算符,但以前没有这样做的经验。
会是这样的吗?
SELECT * FROM myMembers WHERE id='$id'
UNION
SELECT * FROM blocked WHERE id!='$id'
UNION
.
.
.
只是感觉不对...我的数据库方案是:
myMembers
-----------------------
id username
-----------------------
1 x
2 y
3 z
Blocked
---------------------------------------------------------
id mem1 mem2
---------------------------------------------------------
1 2 1
2 4 1
mem2
= 执行阻止的用户。
Your guidance is really appreciated on the following matter.
I am trying to display a list of users (to a user) by eliminating the users that already exist in other his/her lists.
For example, I want to display all my sites users to a user, minus his blocked list.
I believe I need to use the UNION operator, but have no previous experience in doing so.
would it be something like?
SELECT * FROM myMembers WHERE id='$id'
UNION
SELECT * FROM blocked WHERE id!='$id'
UNION
.
.
.
Just doesn't feel right... My database scheme is:
myMembers
-----------------------
id username
-----------------------
1 x
2 y
3 z
Blocked
---------------------------------------------------------
id mem1 mem2
---------------------------------------------------------
1 2 1
2 4 1
mem2
= the user doing the blocking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其中 userid 是您要向其显示列表的用户的 ID
where userid is the id of the user to whom you are displaying the list
怎么样:
How about the following: