select top(1) m.* from
(
select * from tb1 a
unpivot
([name] for field in([a1], [a2], [a3], [a4])) b
) m
inner join
(
select * from tb2 a
unpivot
([name] for field in([a1], [a2], [a3], [a4])) b
) n
on m.field = n.field
where ISNULL(n.[name], '') = ''sql="以上语句"怎么写
(
select * from tb1 a
unpivot
([name] for field in([a1], [a2], [a3], [a4])) b
) m
inner join
(
select * from tb2 a
unpivot
([name] for field in([a1], [a2], [a3], [a4])) b
) n
on m.field = n.field
where ISNULL(n.[name], '') = ''sql="以上语句"怎么写
sql=sql & " (select * from tb1 aunpivot([name] for field in([a1], [a2], [a3], [a4]))b)m "
sql=sql & " inner join "
sql=sql & " (select * from tb2 a unpivot ([name] for field in([a1], [a2], [a3],[a4]))b)n "
sql=sql & " on m.field = n.field where ISNULL(n.[name], '') = ''"
不知道,在SQL专区求的语句
strsql=strsql & " ( " & vbcrlf
strsql=strsql & " select * from tb1 a " & vbcrlf
strsql=strsql & " unpivot " & vbcrlf
strsql=strsql & " ([name] for field in([a1], [a2], [a3], [a4])) b " & vbcrlf
strsql=strsql & " ) m " & vbcrlf
strsql=strsql & " inner join " & vbcrlf
strsql=strsql & " ( " & vbcrlf
strsql=strsql & " select * from tb2 a " & vbcrlf
strsql=strsql & " unpivot " & vbcrlf
strsql=strsql & " ([name] for field in([a1], [a2], [a3], [a4])) b " & vbcrlf
strsql=strsql & " ) n " & vbcrlf
strsql=strsql & " on m.field = n.field " & vbcrlf
strsql=strsql & " where ISNULL(n.[name], '') = '' " & vbcrlf