Hello, the task is to pull information about users and their latest records from the database that I have -

SELECT * FROM `users` LEFT JOIN `news` ON (`users`.`user_name` = `news`.`user_name`) ORDER BY `user_points` DESC HAVING (`news`.`news_date` = MAX(`news`.`news_date`)) 

I get a syntax error, what could be the problem? Thank you very much in advance!

  • one
    Maybe so? SELECT * FROM users LEFT JOIN (SELECT news. * FROM news join (SELECT user_name, MAX (news_date) AS news_date FROM news by user_name) a ON news.user_name = a.user_name) b ON ( users . user_name = b. user_name ) ORDER BY user_points - alexlz

1 answer 1

Try to pre-check the syntax of your request http://developer.mimer.se/validator/parser200x/index.tml#parser