如何合并两个select语句结果? [英] How to merge two select statements results?
本文介绍了如何合并两个select语句结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 tbl_Product_Master 其中 Prod_Name 喜欢 ' m %'
选择 Prod_Name 来自 tbl_Product_Master 其中 Prod_Name 不 喜欢 ' m%'
解决方案
这是一个相当简单的任务。
由于两个Prod_Name值看起来是相同的类型,使用UNION
[ ^ ]条款。
从tbl_Product_Master中选择Prod_Name,其中Prod_Name喜欢''m%''按Prod_Name排序asc< br />
UNION< br />
从tbl_Product_Master中选择Prod_Name,其中Prod_Name不喜欢''m%'' < br />
请注意,这将删除所有重复的值。
有一种更简单的方法:
选择 Prod_Name 来自 tbl_Product_Master 其中 Prod_Name 喜欢 ' m%' 或 Prod_Name 不 喜欢 ' m%'
在这种情况下是:
选择 Prod_Name / span> tbl_Product_Master
我自己解决........
选择 Prod_Name 来自 tbl_Product_Master 其中 Prod_Name 喜欢 ' m%'
< span class =code-keyword> union all
select Prod_Name < span class =code-keyword>来自 tbl_Product_Master 其中 Prod_Name 不 喜欢 ' m%'
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%'
select Prod_Name from tbl_Product_Master where Prod_Name not like 'm%'
解决方案
This is a fairly simple task.
Since the two Prod_Name values appear to be the same type, use theUNION
[^] clause.
select Prod_Name from tbl_Product_Master where Prod_Name like ''m%'' order by Prod_Name asc<br /> UNION<br /> select Prod_Name from tbl_Product_Master where Prod_Name not like ''m%''<br />
Note that this will remove all duplicate values.
There is a simpler way:
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%' OR Prod_Name not like 'm%'
Which in this case is:
select Prod_Name from tbl_Product_Master
i solve my self........
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%' union all select Prod_Name from tbl_Product_Master where Prod_Name not like 'm%'
这篇关于如何合并两个select语句结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文