Seleting records

This is a discussion on Seleting records within the PHP General forums, part of the PHP Programming Forums category; Hello, My news table has a year field as such Year -------- 2000 2000 2001 2001 2003 2005 2005 I was ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-17-2005
Simon Allison
 
Posts: n/a
Default Seleting records

Hello,



My news table has a year field as such



Year

--------

2000

2000

2001

2001

2003

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


Reply With Quote
  #2 (permalink)  
Old 03-17-2005
David Robley
 
Posts: n/a
Default Re: Seleting records

Simon Allison wrote:

> Hello,
>
>
>
> My news table has a year field as such
>
>
>
> Year
>
> --------
>
> 2000
>
> 2000
>
> 2001
>
> 2001
>
> 2003
>
> 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?


Use mysql DISTINCT

SELECT DISTINCT(year-field) FROM table
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:04 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0