asp.net c# Sql server 2000...
有4个表:
表1的字段是:
id 自动编号
const 内容
2id 等于表2的2id
3id 等于表3的3id
4id 等于表4的4id表2的字段是:
2id 自动编号
const2 内容表3的字段是:
3id 自动编号
const3 内容表4的字段是:
4id 自动编号
const4 内容我现在需要把表1,表2,表3,表4的const,const2,const3,const4取出来放在一张表上谢谢
有4个表:
表1的字段是:
id 自动编号
const 内容
2id 等于表2的2id
3id 等于表3的3id
4id 等于表4的4id表2的字段是:
2id 自动编号
const2 内容表3的字段是:
3id 自动编号
const3 内容表4的字段是:
4id 自动编号
const4 内容我现在需要把表1,表2,表3,表4的const,const2,const3,const4取出来放在一张表上谢谢
解决方案 »
- 时间格式转换datetime转换到string
- 与windows service交互的问题,大虾进~
- 安装WEB项目后IIS权限问题
- 用js 给服务器控件赋值,为什么页面刷新一次控件的text失去呢
- [求助]从数据库中读取新闻标题的这种效果如何实现
- 怎样将字符串“2006/1/1 13:23”分别取出其中的年和月和日,需要转先换成日期型吗?
- Button.Attributes.Add("OnClick", "return confirm('确定吗?')");是怎么用的啊??请指点……
- 高难度问题!绝对高手请进
- 命名空间“System.Web”中不存在类型或命名空间名称“Helpers”
- DATAGRID定制模板中,怎样加入单选列表控件?
- 求救:ConnectionString 属性尚未初始化
- 关于DataGrid中的绑定
inner join b2 on b1.id2=b2.id2
inner join b3 on b1.id3=b3.id3
inner join b4 on b1.id3=b4.id4
inner join b2 on b1.[2id]=[b2.2id]
inner join b3 on b1.[3id]=[b3.3id]
inner join b4 on b1.[4id]=[b4.4id]
select a.*,b.*,c.*,d.*
from 表1 as a
inner join 表2 as b on a.2id= b.2id
inner join 表3 as c on a.3id= b.2id
inner join 表4 as d on a.4id= b.2id这是竖排
select a.id,a.const,'表1' as Re
from 表1 as a
where a.id =10
union
select b.id,b.const,'表2'
from 表2 as b
where exists(
select 8 from 表1 as a
where a.2id= b.2id and a.id =10)
union
select c.id,c.const,'表3'
from 表3 as c
where exists(
select 8 from 表1 as a
where a.3id= c.3id and a.id =10)
union
select d.id,d.const,'表4'
from 表4 as d
where exists(
select 8 from 表1 as a
where a.4id= d.4id and a.id =10)
union all
select [b2].[const2] from [b2]
union all
[b3].[const3] from [b3]
union all
[b4].[const4] from [b4]
inner join b2 on b1.[2id]=[b2.2id]
inner join b3 on b1.[3id]=[b3.3id]
inner join b4 on b1.[4id]=[b4.4id]这个比较好一些
select b1.const,b2.const2,b3.const3,b4.const4 from b1
inner join b2 on b1.id2=b2.id2
inner join b3 on b1.id3=b3.id3
inner join b4 on b1.id3=b4.id4
纵向排列
select [b1].[const] from [b1]
union all
select [b2].[const2] from [b2]
union all
[b3].[const3] from [b3]
union all
[b4].[const4] from [b4]
inner join b2 on b1.[2id]=b2.[2id]
inner join b3 on b1.[3id]=b3.[3id]
inner join b4 on b1.[4id]=b4.[4id]
from 表1 a, 表2 b, 表3 c, 表4 d
where a.[id] = b.[2id] and a.[id] = c.[3id] and a.[id] = d.[4id]