Page 1 of 1

How to get only different values in field?

Posted: Sun Dec 19, 2004 9:22 am
by Czar
A quick one:

I have a field "year" in my table. The table holds records from several years and i want to print a list of different years in DB. For example if i have records from 1999, 2001, 2002 and 2005, i want to print menu where those years are links to corresponding pages.

like:

1999
2001
2002
2005

Table holds several records per year, so there may be some 500 records varying from year 1982 to 2004. I just need a list of those years.

Can't figure out how to query them...

If i throw a query, like SELECT * FROM tbl and print years in while loop i get that 500 rows and that is NOT what i want...

Help.

Posted: Sun Dec 19, 2004 11:33 am
by timvw
either use distinct timestamp or group by year(timestamp)