Hi
I want to retrieve unique values from table
if i have table like this i want query retrieve unique values (2004,2007)
±-----±-+
| id | year |
±-----±-+
| 1 | 2004|
| 1 | 2008|
| 1 | 2008|
| 1 | 2008|
| 2 | 2007|
| 2 | 2006|
| 2 | 2006|
| 2 | 2006|
±-----±-+
any help?
r937
3
if you have table like that, then you have overlooked declaring a PRIMARY KEY, which every table should have
DISTINCT will return (2004-2008-2007-2006) but i want to retrieve (2004-2007)
r937
5
SELECT CONCAT('(',MIN(year),'-',MAX(year),')')
FROM daTable
SELECT year
FROM table
GROUP BY year
HAVING COUNT(*) = 1