RE: Select distinct year from unix timestamp

2004-05-16 Thread Dathan Vance Pattishall
R u sure your printing out the correct array (hash) field? Did you connect to the db? Is mysql_error reporting an error? DVP Dathan Vance Pattishall http://www.friendster.com -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of T. H. Grejc Sent: Sunday, May

Re: Select distinct year from unix timestamp

2004-05-16 Thread John Fawcett
From: T. H. Grejc Hello, I'm trying to select all distinct years from a unixtimestamp field in MySQL database (3.23.56). I have a query: SELECT DISTINCT YEAR(date_field) As theYear FROM table but PHP gives me an empty array. What am I doing wrong? TNX I think you need this

Re: Select distinct year from unix timestamp

2004-05-16 Thread Paul DuBois
At 22:27 +0200 5/16/04, John Fawcett wrote: From: T. H. Grejc Hello, I'm trying to select all distinct years from a unixtimestamp field in MySQL database (3.23.56). I have a query: SELECT DISTINCT YEAR(date_field) As theYear FROM table but PHP gives me an empty array. What am I doing wrong?

Re: Select distinct year from unix timestamp

2004-05-16 Thread T. H. Grejc
John Fawcett wrote: From: T. H. Grejc Hello, I'm trying to select all distinct years from a unixtimestamp field in MySQL database (3.23.56). I have a query: SELECT DISTINCT YEAR(date_field) As theYear FROM table but PHP gives me an empty array. What am I doing wrong? TNX I think you need this

Re: Select distinct year from unix timestamp

2004-05-16 Thread T. H. Grejc
Paul DuBois wrote: At 22:27 +0200 5/16/04, John Fawcett wrote: From: T. H. Grejc Hello, I'm trying to select all distinct years from a unixtimestamp field in MySQL database (3.23.56). I have a query: SELECT DISTINCT YEAR(date_field) As theYear FROM table but PHP gives me an empty array. What

Re: Select distinct year from unix timestamp

2004-05-16 Thread John Fawcett
From: T. H. Grejc How can I add more fields to query. If I write: SELECT DISTINCT FROM_UNIXTIME(created, '%Y %M'), other_field FROM table_name ORDER BY created DESC I loose distinction (all dates are displayed). TNX I don't think distinction is lost. All the rows should still be distinct

Re: [SPAM]Re: Select distinct year from unix timestamp

2004-05-16 Thread John Fawcett
From: Paul DuBois At 22:27 +0200 5/16/04, John Fawcett wrote: Year does not operate on a unix timestamp. Sure it does: mysql select t, year(t) from tsdemo1; ++-+ | t | year(t) | ++-+ | 20010822133241 |2001 | |

Re: Select distinct year from unix timestamp

2004-05-16 Thread T. H. Grejc
John Fawcett wrote: From: T. H. Grejc How can I add more fields to query. If I write: SELECT DISTINCT FROM_UNIXTIME(created, '%Y %M'), other_field FROM table_name ORDER BY created DESC I loose distinction (all dates are displayed). TNX I don't think distinction is lost. All the rows should still

Re: [SPAM]Re: Select distinct year from unix timestamp

2004-05-16 Thread Paul DuBois
At 0:25 +0200 5/17/04, John Fawcett wrote: From: Paul DuBois At 22:27 +0200 5/16/04, John Fawcett wrote: Year does not operate on a unix timestamp. Sure it does: mysql select t, year(t) from tsdemo1; ++-+ | t | year(t) | ++-+ |

Re: Select distinct year from unix timestamp

2004-05-16 Thread John Fawcett
From: T. H. Grejc I'm creating news archive and it should be sorted by months: January 2004 (news count is 56) February 2004 (48) ... So you need to use GROUP BY and COUNT. The format is like this: select monthandyear,count(othercolumn) from t group by monthandyear in your case