首页 新闻 会员 周边 捐助

sql查询UNION的问题

0
悬赏园豆:20 [已解决问题] 解决于 2019-07-22 16:39

SELECTFROM
(SELECT
FROM order_gtncoin where NOT buy_uid IN (13311787)AND NOT sale_uid IN (13319623)
UNION
SELECTFROM order_gtncoin where NOT buy_uid IN (13319623)AND NOT sale_uid IN (13311787)
UNION
SELECT
FROM order_gtncoin where NOT buy_uid IN (13319623)AND NOT sale_uid IN (13319623)
UNION
SELECT*FROM order_gtncoin where NOT buy_uid IN (13311787)AND NOT sale_uid IN (13311787)
) AS a

使用UNION后达不到想要的结果
需求:查询除了13311787,13319623这两个uid相互成交和这两个uid自己和自己成交的记录
看不出是什么问题,执行和是这样
求指教,在线等挺急的。。。

路过的一个小测试的主页 路过的一个小测试 | 初学一级 | 园豆:3
提问于:2019-07-22 15:38
< >
分享
最佳答案
0
select * from order_gtncoin where
(buy_uid = '13311787' and sale_uid = '13319623') or 
(buy_uid = '13319623' and sale_uid = '13311787') or 
(buy_uid = '13311787' and sale_uid = '13311787') or 
(buy_uid = '13319623' and sale_uid = '13319623') 
收获园豆:20
会长 | 专家六级 |园豆:12463 | 2019-07-22 15:50

刚才说错了,是除了那两个账号的结果

路过的一个小测试 | 园豆:3 (初学一级) | 2019-07-22 15:57

@打我队友:

select * from order_gtncoin where not (
(buy_uid = '13311787' and sale_uid = '13319623') or 
(buy_uid = '13319623' and sale_uid = '13311787') or 
(buy_uid = '13311787' and sale_uid = '13311787') or 
(buy_uid = '13319623' and sale_uid = '13319623') )
会长 | 园豆:12463 (专家六级) | 2019-07-22 17:00

@会长: 谢谢老哥

路过的一个小测试 | 园豆:3 (初学一级) | 2019-07-22 17:15
其他回答(1)
0

SELECT
*
FROM
order_gtncoin
WHERE
id NOT IN (
SELECT
id
FROM
order_gtncoin
WHERE
(
buy_uid = 13311787
AND sale_uid = 13319623
)
OR (
buy_uid = 13319623
AND sale_uid = 13311787
)
OR (
buy_uid = 13319623
AND sale_uid = 13319623
)
OR (
buy_uid = 13311787
AND sale_uid = 13311787
)
);

路过的一个小测试 | 园豆:3 (初学一级) | 2019-07-22 16:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册