select a.*
,t.name
from a
join (
select *,'a' as 'type' from b
union
select *,'b' from c
)t on a.aORbID=t.id
and a.type=t.type
,t.name
from a
join (
select *,'a' as 'type' from b
union
select *,'b' from c
)t on a.aORbID=t.id
and a.type=t.type
解决方案 »
- 求sql2005查询不重复语句
- 存储过程可不可以带两个输入参数
- sql server 里如何取得服务器的日期和时间,并以自定义的格式插入数据库?
- 奇怪的数据库连接问题
- 将数字连接成字符串问题
- 数据库中没有这条记录时新增,有这条记录时则修改,想用一条sql语句写,怎么实现?
- Cannot resolve collation conflict for equal to operation 是什么错误啊?
- 关于数据重复的问题··大虾近来帮忙?
- 行列转置
- 初学者问一个弱智问题!
- 导出成dbf文件时,如果dbf文件名是变量怎么办
- 我不知道大家在设置小数字段的时候,一般是使用float ? 还是使用decimal类型??比如说财务的金额字段类型一般都设置什么?
when 'a' then b.name
when 'b' then c.name
when 'c' then d.name
when 'd' then e.name
end
from a left join b on a.aorbid=b.id
left join c on a.aorbid=c.id
left join d on a.aorbid=d.id
--依此类推