Jump to content

SPOOKMAN

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

SPOOKMAN's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. First off Hi All, I need help with a query. I have 2 tables users and sessions in users I have (user, status, ip) in sessions I have (sessionid, user, stoptime) In users there user is unique and in sessions the sessionid is unique. I what to select the max sessionid for all users in users table I worte this query but it takes forever to run and never seems to finish, the sessions table has about 50000 rows. SELECT MAX(sessionid) FROM sessions s1 WHERE s1.users IN (SELECT u1.user from users u1) group by s1.username this returns all the correct sessions for each users SELECT * FROM sessions s2 WHERE s2.sessionid IN (SELECT MAX(sessionid) FROM sessions s1 WHERE s1.users IN (SELECT u1.user from users u1) group by s1.username) This runs forever I am looking for a query that returns the results user,status,ip,sessionid,stoptime I have not included the join in the code as I an batteling with getting the correct info back from the above codes
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.