日期:2014-05-20 浏览次数:20698 次
select name from table1 where orderID = '123' select name from table2 where age = '35' 这两条语句能合成一条吗?如果能合并,怎么在rs里面分辨哪个是表1的结果哪个是表2的结果
SELECT name, 'table1' AS category FROM table1 WHERE ... UNION ALL SELECT name, 'table2' AS category FROM table2 WHERE ...
------解决方案--------------------
select name,'表1' as tempColumn from table1 where orderID = '123' union all select age,'表2' as tempColumn from table2 where age = '35'