复制代码
- select xmmc from sbs where xh = ‘123456’
|
查询结果为:
复制代码
- select xmmc from sbs where xh = ‘7890’
|
查询结果为:
欲把两个查询结果纵向连接起来,只需要执行以下SQL:
复制代码
- (select xmmc from sbs where xh = ‘123456’) union (select xmmc from sbs where xh = ‘7890’ )
|
查询结果为:
用法约束:
1. 前后select 的字段数必须一样。但select的字段名不一定要一致
2. 后可加order by 但必须是select 中出现的字段名
3. 以上使用于sql server ,其它数据库下尚未测试