Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?
| From: | Chris | Date: | Mon, 03 Aug 2009 04:33:42 +0000 |
| Subject: | Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column? | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46383@lists.php.net to get a copy of this message | ||
Govinda wrote:
Provide an example of what you have now, and what you want to get back. We're all just guessing what you're trying to do so an example might help us understand and help you better. -- Postgresql & php tutorials http://www.designmagick.com/Oops, forgot to mention that with the alias you can change the ORDER BY clause to use the aliased column data: ORDER BY solarLandingDate DESC this will only use the returned data instead of the entire column.Niel, Bastien, thanks for your efforts to lead me to understanding this! I tried everything you both suggested. Ideally I would have some clear docs that outline the syntax for me, for such an example as I need.. and I would be able to check my code myself. Meanwhile, In every case, I just get every record in the table back as a result. So then I thought, "try and make even a *simple* DISTINCT work, and then move on to the date thing"... so I try this: //$foundTrackingRows=mysql_query("SELECT DISTINCT solarLandingDir, solarLandingIP, solarLandingDir, solarLandingDateTime FROM ".$whichTable." ORDER BY solarLandingDateTime DESC LIMIT $Maxrecs2Show") or die("query failed: " .mysql_error()); In all the records in this table, there are only 3 possible values in the 'solarLandingDir' column (TINYTEXT): diysolar solar_hm (null) but I still get all the records back, with each distinct 'solarLandingDir' column value represented several times.If you are aliasing a column it is better to use the optional AS keyword to avoid confusion. MySQL's DATE function returns dates formatted as 'YYYY-MM-DD' so DATE_FORMAT is not needed here.