2012-12-06 107 views
0

我怎樣才能得到這個在MySQL? 我想用下面的查詢只顯示一個時間在重複顯示標題只重複一次

+-----------------------------+-------------+-------------+----------+ 
| title      | created  | updated  | category | 
+-----------------------------+---------------------+----------------- 
| What If I Get Sick and Die? | 2008-12-30 | 2009-03-11 | angst | 
|        | 2009-02-28 | NULL  | humor | 
|        | 2009-03-02 | NULL  | advice | 
|        | 2009-03-17 | NULL  | humor | 
| The Size of Our Galaxy  | 2009-04-03 | NULL  | science | 
|        | 2009-03-02 | NULL  | advice | 
|        | 2009-03-17 | NULL  | humor | 
|        | 2009-04-03 | NULL  | science | 
+-----------------------------+---------------------+----------------- 

回答

0

標題和空你可以做到這一點:

SELECT CASE WHEN 
(
    SELECT t1.id 
    FROM tablename t1 
    WHERE t1.title = t.title LIMIT 1 
) = t.id THEN t.title 
ELSE null END AS title 
,t.created 
,t.updated 
,t.category 
FROM tablename t