If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Find max entry in an JOIN

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-11, 02:36
Muiter Muiter is offline
Registered User
 
Join Date: Dec 2008
Location: Netherlands
Posts: 56
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
Reply With Quote
  #2 (permalink)  
Old 03-31-11, 03:25
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 03-31-11, 14:29
Muiter Muiter is offline
Registered User
 
Join Date: Dec 2008
Location: Netherlands
Posts: 56
Yes I have tried all tables as driver, with no result.
Reply With Quote
  #4 (permalink)  
Old 03-31-11, 16:30
Muiter Muiter is offline
Registered User
 
Join Date: Dec 2008
Location: Netherlands
Posts: 56
Solved with WHERE plt_afm.id = (SELECT MAX(id) FROM plaatregistratie_afm WHERE plaat_nr_id = plt_nr.id)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On