作者zeSil (寂静西风)
看板Database
标题[SQL ] MYSQL如何组合唯一化?
时间Thu May 22 23:04:10 2008
使用版本 MySQL 5.0.51
table1
id group1 name1 type1
1 A aaa Write
2 A bbb Report
3 A ccc Read
4 B ddd Write
5 B eee Read
6 B fff Report
7 C ggg Write
将他们组合出来看他们组合类型是如何
我的SQL
SELECT
a.type1 as Type1
, b.type1 as Type2
, count(*) as total
FROM `table1` a, `table1` b
WHERE a.group1=b.group1
AND a.name1 != b.name1
Group by a.type1
Order by 3
可是却会输出
Type1 Type2 Count
Write Report
Write Read
Read Write
Read Report
Report Read
Report Write
(下略)
类似这样的结果
可是我想要的是
Type1 Type2
Write Report
Write Read
Report Read
意思是 (Write, Report) = (Report, Write)
这样MySQL可以办到吗@@?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.165.78.122