Results 1 to 3 of 3

Thread: Getting what I need out of a query...

  1. #1
    Join Date
    Sep 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Getting what I need out of a query...

    Hello. I have data in a "projects" table with "proj_id" (primary key) and "proj_name" columns. I also have a lookup table called "update_progress" with three columns:

    * proj_id (which relates to the proj_id primary key in the "projects" table)
    * updated (a TIMESTAMP that auto-updates the current timestamp on update)
    * progress (a text field)

    Now, I need to display each project title (from the "projects" table) one time, and then I need to display only the most RECENT progress that relates to it (from the new "update_progress" table) after that. This is where I'm having problems...

    I have it so that it's displaying EVERY update (not just the most recent one). So if there's three updates, the project will list three times - once for each update...

    Here's the code that's doing that - please let me know how to fix it. Thanks!:
    Code:
    SELECT projects.proj_id, projects.proj_name,
    CONCAT(DATE_FORMAT(update_progress.updated, '%Y-%m-%d'),': ',update_progress.progress) AS progress
    FROM projects, update_progress
    WHERE projects.proj_id = update_progress.proj_id

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    ORDER BY update_progress.updated LIMIT 1
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    Code:
    ORDER BY update_progress.updated LIMIT 1
    That just gives me one result total, though. I need one result for each project listed.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •