Jump to content

How to select and display record group having only the latest date


ed01

Recommended Posts

What I'm trying to do is the following:

Capture the latest date from any record in the table.

Use that date to create a query to display all records of only that date.

Here's what I have so far...

 

SELECT hometeam, weekdate,day FROM sched_games WHERE day='Saturday' ORDER BY 'weekdate' DESC

 

OUTPUT IS:

hometeam weekdate day

Euro 11/19/2011 Saturday

Crusaders 11/19/2011 Saturday

Cobras 11/26/2011 Saturday

Titans 11/26/2011 Saturday

Porto 9/24/2011 Saturday

Titans 9/24/2011 Saturday

Porto 9/15/2012 Saturday

 

As you can see, the records are not being sorted by the weekdate. Seems like I need to convert the values in the weekdate column so that mysql recognizes them as dates first, and then maybe the sorting will work?

Any help would be much appreciated.

Thanks!

Ed

you are trying to order by the string ('weekdate') instead of the column weekdate

 

and no reason to store the `day` in your table... day can be determined from your weekdate column

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dayname

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.