SELECT A.Session,A.UserId,B.Username FROM TableA A JOIN TableB B ON A.Session = B.Session JOIN UserTable U ON A.UserId = U.UserId WHERE A.UserId = 1 AND B.Username = 'xxx';