带有NULL字段的mysql联合 [英] mysql union with NULL fields
本文介绍了带有NULL字段的mysql联合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mysql UNION
和UNION ALL
运算符是否总是删除其中包含NULL的行吗?
Does the mysql UNION
and UNION ALL
operator always remove rows that have a NULL in them?
我正在执行两个SELECT语句的UNION
-其中一个可能返回其中包含NULL的行.如果这样做的话,它就不会在UNION中包含该行.有办法解决吗?
I am doing a UNION
of two SELECT statements - one of which may return a row with a NULL in it. When it does, it does not include that row in the UNION. Is there a way around this?
推荐答案
UNION/UNION ALL不会删除其中包含NULL的行.
The UNION/UNION ALL does not remove rows with NULL in them.
UNION
删除重复的行; UNION ALL
不会,并且比UNION
快.
UNION
removes duplicate rows; UNION ALL
does not, and is faster than UNION
for it.
检查您的数据&查询您为什么看不到空值的原因.
Check your data & your query for why NULLs you expect to see are not visible.
这篇关于带有NULL字段的mysql联合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文