tableA
id,time,type,name
tableB
id,parentid想生成一个view,
里面把两个表的字段和起来另外能不能在view里面新命名一个字段parentname,值设为以id为where条件的table.name的值
id,time,type,name
tableB
id,parentid想生成一个view,
里面把两个表的字段和起来另外能不能在view里面新命名一个字段parentname,值设为以id为where条件的table.name的值
as
select a.id,a.[time],a.[type],a.[name] as parentname,b.id,b.parentid
from tablea a,tableb b
where a.id = b.id
go
AS
SELECT A.ID,A.[TIME],A.[TYPE],A.[NAME] AS PARENTNAME,B.ID,B.PARENTID
FROM TABLEA A,TABLEB B
WHERE A.ID = B.PARENTID
select a.id,a.[time],a.[type],a.[name],b.id,b.parentid,c.[name] as parentname
from tableA as a join tableB as b on a.id = b.id
join tableA as c on b.parentid = c.id--这样?
as
select a.id,a.[time],a.[type],a.[name],b.id,b.parentid,c.[name] as parentname
from tableA as a join tableB as b on a.id = b.id
join tableA as c on b.parentid = c.id
AS
SELECT……其他的就和查询语句一样了
as
select a.id,a.[time],a.[type],a.[name] as parentname,b.id,b.parentid
from tablea a,tableb b
where a.id = b.id
go
as
select a.id,a.[time],a.[type],a.[name] as parentname,b.id,b.parentid
from tablea a,tableb b
where a.id = b.id
go
as
XXX
go