Mysql
 sql >> Database >  >> RDS >> Mysql

LEFT JOIN ordine e limite

Prova a sostituire:

LEFT JOIN ps a ON a.account_id = fr.author

con:

LEFT JOIN ps a 
  ON a.PrimaryKey                         --- the Primary Key of ps
     = ( SELECT b.PrimaryKey 
         FROM ps AS b 
         WHERE b.account_id = fr.author
         ORDER BY b.level DESC
         LIMIT 1
       )