Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql query the latest duplicate
    primarykey
    data
    text
    <p>EDIT:</p> <p>I'm trying to do a mysql query which will give me the latest entry for duplicates together with those without any duplicates.</p> <p>This is what my table look like:</p> <p>mentor table:</p> <pre><code> mentor_id applicant_id mentor_count mento_email mentor_name mentor_pass 193 92 1 test@yahoo.com test 1234 194 92 2 table@yahoo.com table 4567 195 92 3 lamp@yahoo.com lamp 7890 196 92 1 test@yahoo.com test 1234 197 92 2 table@yahoo.com table 4567 198 92 3 lamp@yahoo.com lamp 7890 </code></pre> <p>mf table:</p> <pre><code> mf_id mentor_id dept contact orgname yrs length sak social char goal resp emomat res others impact evaluation 43 193 math dept 9111111 etc 1 1 e e e e e e e e e good 114 196 math dept 9111111 etc 1 1 e e e e e e e e e good 193 197 sci dept 9222222 org 2 2 n n n n n n n n n medium 194 194 sci dept 9222222 org 2 2 n n n n n n n n n medium 220 195 eng dept 9333333 hello 3 3 q q q q q q q q q bad </code></pre> <p>I tried using this query:</p> <pre><code> SELECT * FROM mentor m1 LEFT JOIN ( SELECT mentor_name, max( mentor_id ) AS maxid FROM mentor m GROUP BY m.mentor_id )m2 ON m1.mentor_name = m2.mentor_name AND m1.mentor_id &lt; m2.maxid LEFT JOIN mf ON m1.mentor_id = mf.mentor_id WHERE m1.applicant_id =833 AND m2.maxid IS NULL ORDER BY m1.mentor_id ASC LIMIT 0 , 30 </code></pre> <p>but this is what happens</p> <pre><code>mentor_id applicant_id mentor_count mentor_email mentor_name mentor_pass mentor_name maxid mf_id mentor_id dept contact orgname yrs length sak social char goal resp emomat res others spirit concept comm impact evaluation /*there is data here but the column for mentor_name onwards is null*/ </code></pre> <p>How can I make it so that the columns for mentor_name onwards is not null but still displays the latest duplicates as well as those without any duplicates?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload