表一:DepartmentItem
字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID Int Y N
ArchitectureID Varchar(40) N 编号
ItemID uniqueidentifier N 关联 Item 表
IndexID Smallint 该部门排序ID
表二:Architecture
字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID archar(40)
Name
Varchar(50)
表三:Item
字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID uniqueidentifier
Name varchar(20)
怎样查出DepartmentItem的ID,DepartmentItem的IndexID和Architecture的name,和Item的name
各位帮忙解决哈
20 个解决方案
#1
好乱啊,这样多美好
//表一:DepartmentItem
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID Int Y N
ArchitectureID Varchar(40) N 编号
ItemID uniqueidentifier N 关联 Item 表
IndexID Smallint 该部门排序ID
//表二:Architecture
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID archar(40)
Name Varchar(50)
//表三:Item
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID uniqueidentifier
Name varchar(20)
#2
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on B.ID=A.ID
left join Item B on C.ID=A.ID
这个你试下
#3
你表1,2,3里面的ID的字符型怎么都不一样啊,这样用Left Join可能会报错...
#4
#5
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
#6
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
测试了一下还是有问题,,
#7
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
冲你头像随手给你写的,都是些基本的
select DepartmentItem.ID,DepartmentItem.IndexID,Architecture.Name,Item.Name from DepartmentItem,Architecture,Item where DepartmentItem.ArchitectureID=Architecture.ID and DepartmentItem.ItemID=Item.ID;
#9
冲你头像随手给你写的,都是些基本的
select DepartmentItem.ID,DepartmentItem.IndexID,Architecture.Name,Item.Name from DepartmentItem,Architecture,Item where DepartmentItem.ArchitectureID=Architecture.ID and DepartmentItem.ItemID=Item.ID;
我试了一下,关键是ID类型不一样啊
#10
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID
试试看
#17
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID
试试看
别误导了,你们还是都把","加上吧,楼主都是直接复制进去执行的
#19
确实是啊!
select
A.ID,
A.IndexID,
B.Name,
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID
//表一:DepartmentItem
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID Int Y N
ArchitectureID Varchar(40) N 编号
ItemID uniqueidentifier N 关联 Item 表
IndexID Smallint 该部门排序ID
//表二:Architecture
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID archar(40)
Name Varchar(50)
//表三:Item
//字段名称 数据类型(大小) 是否主键 是否为空 默认值 描述
ID uniqueidentifier
Name varchar(20)
#2
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on B.ID=A.ID
left join Item B on C.ID=A.ID
这个你试下
#3
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on B.ID=A.ID
left join Item B on C.ID=A.ID
这个你试下
你表1,2,3里面的ID的字符型怎么都不一样啊,这样用Left Join可能会报错...
#4
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on B.ID=A.ID
left join Item B on C.ID=A.ID
恩恩,就是的类型不一样,结果报错
#5
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
#6
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
测试了一下还是有问题,,
#7
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
冲你头像随手给你写的,都是些基本的
select DepartmentItem.ID,DepartmentItem.IndexID,Architecture.Name,Item.Name from DepartmentItem,Architecture,Item where DepartmentItem.ArchitectureID=Architecture.ID and DepartmentItem.ItemID=Item.ID;
#9
冲你头像随手给你写的,都是些基本的
select DepartmentItem.ID,DepartmentItem.IndexID,Architecture.Name,Item.Name from DepartmentItem,Architecture,Item where DepartmentItem.ArchitectureID=Architecture.ID and DepartmentItem.ItemID=Item.ID;
我试了一下,关键是ID类型不一样啊
#10
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID
试试看
#17
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on to_char(B.ID)=A.ID
left join Item C on to_char(C.ID)=A.ID
试下
select
A.ID
A.IndexID
B.Name
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID
试试看
别误导了,你们还是都把","加上吧,楼主都是直接复制进去执行的
#19
确实是啊!
select
A.ID,
A.IndexID,
B.Name,
C.Name
from DepartmentItem A
left join Architecture B on CAST(B.ID AS Varchar)=A.ArchitectureID
left join Item C on C.ID = A.ItemID