Jump to content

strugging with distinct


michaellunsford

Recommended Posts

I'm trying to pull a list of projects in the order that they were last updated. There are a few tables, but I thought to just query the updates table so I can sort by the last updated item. I thought it was pretty simple stuff, but I just can't seem to get the query right. Any help or insights would be grand. Here's what I've tried so far:

 

//This works great except that there are multiple updates per project - so I get loads of duplicates.
"SELECT `project`,`date` FROM `table` ORDER BY `date` DESC"

//This returns exactly what the previous query does
"SELECT DISTINCT(`project`), `date` FROM `table` ORDER BY `date` DESC"

//This returns rows with the wrong date (not sorting by date before grouping), and thereby is in the wrong order
"SELECT `project`,`date` FROM `table` GROUP BY `project` ORDER BY `date` DESC"

//This one says "you have an error in your mysql syntax"
"SELECT `project`,`date` FROM `table` ORDER BY `date` DESC GROUP BY `project`"

 

Link to comment
Share on other sites

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.