Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.