MySQL records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

MySQL records

Post by thesimon »

Hello,

My news table(mysql) has a year field as such

Year
--------
2000
2000
2001
2001
2003
2005
2005
2005

I was wondering if you could select from this table so you only get one of each year, so the output would be

2000
2001
2003
2005

Is this possible, I was trying to think of an algorithm that would work, but I have had no luck yet?



Thanks,

Simon
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: DISTINCT or GROUP BY
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

Legend

Post by thesimon »

Where would we be without smart people, thanks so much for your help, it works :)
Post Reply