MySQL查询返回用户的收件人列表
16lz
2021-01-22
I am stuck with Mysql query
here is a table
我坚持使用Mysql查询这里是一个表
SNDR |RCVR
--------+-------
admin |bob
admin |roy
roy |admin
alice |admin
admin |eve
jesper |admin
marco |roy
bob |eve
Now in case of a private msg I want user admin's recipients list
That is all the sender where rcvr="admin" along with all the rcvr where sndr="admin" but only the unique value I am expecting result something like this
现在在私有消息的情况下,我想要用户管理员的收件人列表这是rcvr =“admin”的所有发件人以及所有rcvr,其中sndr =“admin”但只有我期望的唯一值结果是这样的
bob
roy
alice
eve
jesper
Can anybody help me with the query am going to use it on php , database is mysql 5.5.27
任何人都可以帮我查询我将在php上使用它,数据库是mysql 5.5.27
3 个解决方案
#1
1
You should be able to use a UNION query to get the result:
您应该能够使用UNION查询来获取结果:
select s.rcvr person
from yt s
where s.sndr = 'admin'
union
select r.sndr
from yt r
where r.rcvr = 'admin';
See SQL Fiddle with Demo
请参阅SQL Fiddle with Demo
更多相关文章
- 字体图标的引入和通过媒体查询改变导航样式
- HTML样式和常用选择器
- 字体图标的引用和自定义样式/媒体查询的使用
- 数据库的CURD操作、PDO本质与原理的学习
- CSS之伪类选择器和简单盒子简单案例
- 伪类选择器与盒模型常用属性
- 伪类选择器-结构伪类、根据位置选择匹配
- 7.4——常用标签与应用场景之表格与单元格
- css伪类选择器和盒模型