select id,name,pass from A where type = 1
union
if((select id,name,pass from A where type =1) <> 0)
begin
select id,name,pass from B
end
else
begin
select id,name,pass from C
end像这种类型的表查询,分别独立查询时是可以的,但是一用union合并查询就不行了。
假设A、B、C三表结构完全不同,但是有部分字段名都是相同的。
union
if((select id,name,pass from A where type =1) <> 0)
begin
select id,name,pass from B
end
else
begin
select id,name,pass from C
end像这种类型的表查询,分别独立查询时是可以的,但是一用union合并查询就不行了。
假设A、B、C三表结构完全不同,但是有部分字段名都是相同的。
解决方案 »
- 请教 关于 一个sql语句的问题
- sql2008 性能就这么烂么?烂!烂!烂!大家进来研究,是我难为它么?
- 如何单向同步不同数据库服务器的两张表
- 一个菜鸟的问题---关于两种数据库冲突的问题????(在线等!!!)
- 数据库连接问题。急!!
- 能否往存储过程中传入一个字符串数组???
- 一个跨表查询的问题忘高手指点。
- 问一个问题,一台SYBASE服务器上最多支持建立多少个数据库?
- update user set user=88 where datediff('hh',logintime,now()) > 10;我想比较数据库中logintime也当前时间是否相差10分钟
- select查询结果是0的想出来的时候变成空白怎么写语句
- 两字段求和写入第三个字段
- 大家帮忙,一问题大家不太忙就点一下。小弟谢谢了
begin
select id,name,pass from A where type = 1
union all
select id,name,pass from B
end
else
begin
select id,name,pass from C
end
if((select id,name,pass from A where type =1) <> 0)
begin
select id,name,pass from A where type = 1
union
select id,name,pass from B
end
else
begin
select id,name,pass from A where type = 1
union
select id,name,pass from C
end
begin
select ltrim(id),ltrim(name),ltrim(pass) from A where type = 1
union
select ltrim(id),ltrim(name),ltrim(pass) from B
end
else
begin
select ltrim(id),ltrim(name),ltrim(pass) from A where type = 1
union
select ltrim(id),ltrim(name),ltrim(pass) from C
end
——这是啥玩意啊???
严重的语法错误,居然还有人复制、粘贴来用?!
没有实事求是的精神。