這裏是代碼是否有寫冗長的where子句
DECLARE @List TABLE (n nvarchar(50));
INSERT INTO @list (n) VALUES ('A'),('B'),('C'),('D'),('E');
SELECT
(t1.n)
+ (t2.n)
+ (t3.n)
+ (t4.n)
+(t5.n)
FROM @list AS t1
JOIN @list AS t2
ON 1=1
JOIN @list AS t3
ON 1=1
JOIN @list AS t4
ON 1=1
JOIN @list AS t5
ON 1=1
WHERE
not t1.n = t2.n
and not t1.n = t3.n
and not t1.n = t4.n
and not t1.n = t5.n
and not t2.n = t3.n
and not t2.n = t4.n
and not t2.n = t5.n
and not t3.n = t4.n
and not t3.n = t5.n
and not t4.n = t5.n
我需要簡化任何短期和簡單的方式where子句像(其中T1.n,T2.n,T3.n ,. T4.n,T5.n不equl對方)
在此先感謝
哇這更是酷感謝 –