Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Location
    Netherlands
    Posts
    58

    Unanswered: Find max entry in an JOIN

    I have this query:

    Code:
    SELECT
    plt_id.id AS id,
    plt_id.dikte AS dikte,
    plt_id.dikte_gemeten AS dikte_gemeten,
    plt_id.attest AS attest,
    plt_nr.plaat_id_id AS plaat_nr_id,
    plt_nr.plaat_no AS plaat_no,
    plt_nr.moeder_plaat AS moeder_plaat,
    plt_nr.locatie AS locatie,
    plt_afm.aantal AS aantal,
    plt_afm.lengte AS lengte,
    plt_afm.breedte AS breedte,
    FROM plaatregistratie_afm AS plt_afm
    LEFT JOIN plaatregistratie_nr AS plt_nr
    ON plt_nr.id = plt_afm.plaat_nr_id
    LEFT JOIN plaatregistratie_id AS plt_id
    ON plt_id.id = plt_nr.plaat_id_id
    Is there an way so see of each latest entry in plaatregistratie_afm per plt_nr.plaat_no?

    I have tried with no succes:
    MAX(plt_afm.plaat_nr_id) AS afm_plaat_nr_id,
    And
    GROUP BY plt_nr.id

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi,

    You are asking "Is there an way so see of each latest entry in plaatregistratie_afm per plt_nr.plaat_no?". Have you considered changing the order of your tables and using plt_nr as the driver with left joins to the other tables? Also do you need to have LEFT JOIN's in your query and use JOIN's instead?
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Dec 2008
    Location
    Netherlands
    Posts
    58
    Yes I have tried all tables as driver, with no result.

  4. #4
    Join Date
    Dec 2008
    Location
    Netherlands
    Posts
    58
    Solved with WHERE plt_afm.id = (SELECT MAX(id) FROM plaatregistratie_afm WHERE plaat_nr_id = plt_nr.id)

Posting Permissions

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