1
我有兩個SQL臨時表#Temp1
和#Temp2
。從多組記錄中查找entryno集合
我想得到entryno
其中包含一套臨時表二。
例如:#Temp2
有8條記錄。我想搜索#Temp1
,其中包含一組來自#Temp1
的記錄。
CREATE TABLE #Temp1 (entryNo INT, setid INT, measurid INT,measurvalueid int)
CREATE TABLE #Temp2(setid INT, measurid INT,measurvalueid int)
INSERT INTO #Temp1 (entryNo,setid,measurid,measurvalueid)
VALUES (1,400001,1,1),
(1,400001,2,110),
(1,400001,3,1001),
(1,400001,4,1100),
(2,400002,5,100),
(2,400002,6,102),
(2,400002,7,1003),
(2,400002,8,10004),
(3,400001,1,1),
(3,400001,2,110),
(3,400001,3,1001),
(3,400001,4,1200)
INSERT INTO #Temp2 (setid,measurid,measurvalueid)
VALUES (400001,1,1),
(400001,2,110),
(400001,3,1001),
(400001,4,1100),
(400002,5,100),
(400002,6,102),
(400002,7,1003),
(400002,8,10004)
我想輸出
EntryNo
1
2
它包含兩組。
之一是:
(400001,1,1),
(400001,2,110),
(400001,3,1001),
(400001,4,1100)
二是:
(400002,5,100),
(400002,6,102),
(400002,7,1003),
(400002,8,10004)