0

I have two tables. Member information and login entries. I am simply trying to display the member information table sorted by the last login access date. So i created this query, but it is extremely slow. Is there a better way to write it?

SELECT
    menmembers.memb_id, 
    menmembers.firstname, 
    menmembers.lastname, 
    (SELECT Max(trank.datetr) AS MaxOfdatetr
        FROM trank 
        where trank.cod_usr=menmembers.memb_id;) AS LastLogin
FROM menmembers;
Michael Green
  • 24,839
  • 13
  • 51
  • 96
Nelson
  • 1
  • 1
  • Your query has a syntax error: What's that semicolon doing in the subquery? 2. Which DBMS are you using? 3. Please show us the execution plan.
  • – Colin 't Hart Aug 20 '14 at 08:28