Reply to Re: ORDER BY order of months

Your name:

Reply:


Posted by Oli Filth on 11/15/05 16:00

kenoli wrote:
> I an using only one field to store the date info, which is a date type.
> Here is the format, as exported from the actual table:
>
> `date` date NOT NULL default '0000-00-00'
>
> Here is the query (The two fields accessed are date, summary):
>
> $query = "SELECT date_format(date, '%c.%e.%Y') as date, summary
> FROM tbl_news_stories ORDER BY date DESC";
> $result = mysql_query ($query);
>
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
>
> echo "<p>{$row['date']} - {$row['summary']}</p>";
>

Well, the fact that you're using a column name as an alias in the
SELECT clause is probably why this isn't working.

The alias "date" is overriding the field name "date" when MySQL
performs the ORDER BY instruction, hence the output strings are being
sorted rather than the original date data.

Not to mention that you're using a reserved keyword "date" as a field
name without escaping it in your query!.

--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация