AΪ×Ô¶¯±êʾÁУ»²éѯ³öÀ´µÄ½á¹ûΪ ad£¬ac£¬ab£¬bd£¬bc £» sql¸ÃÔõôд£¿ÔõôûÓÐcd SELECT DISTINCT T1.B+T2.B from TB T1 INNER JOIN TB T2 WHERE T1.B <T2.B SQL code: --> Title : Generating test data [tb] --> Author : --> Date : 2009-12-03 11:11:25 if object_id('[tb]') is not null drop table [tb] go create table [tb] (A int,B nvarchar(2)) insert into [tb] select 1,'a' union all select 2,'b' union all select 3,'c' union all select 4,'d'
select a.b+b.b from [tb] a, [tb] b where a.a<B.a /*
---- ab ac bc ad bd cd
(6 個資ÁÏÁÐÊܵ½Ó°響)
*/
SQL code:
--> ²âÊÔÊý¾Ý£º[TB] if object_id('[TB]') is not null drop table [TB] create table [TB]([A] int,[B] varchar(1)) insert [TB] select 1,'a' union all select 2,'b' union all select 3,'c' union all select 4,'d'
select A.B+B.B from [TB] A,TB B where A.B<>B.B order by 1