select query

Discussion in 'MySQL' started by srini_r85, May 27, 2010.

  1. #1
    hi,

    i have two tables sessions and location.

    session :uid,sid,ip have three fields

    location:lid,address,name,lat,lng

    i need sql query to select the address from location table where uid equal to lid.

    plz any one help me find out.

    thanks
     
    srini_r85, May 27, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    SELECT address
    FROM   location
           INNER JOIN sessions
             ON location.lid = sessions.uid  
    Code (markup):
    If you need to query based on a specific session it would be (assuming that the sid is your user's session_id):

    SELECT address
    FROM   location
           INNER JOIN sessions
             ON location.lid = sessions.uid
    WHERE  sessions.sid = 'USERS_SESSION_ID'  
    Code (markup):
     
    jestep, May 28, 2010 IP
  3. ashu_sood08

    ashu_sood08 Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    select
    b.adress from location b,session a where a.uid=b.lid;
     
    ashu_sood08, Jun 4, 2010 IP