1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SQl query for location

Discussion in 'General PHP and MySQL Discussions' started by jellytoe, Sep 13, 2015.

  1. jellytoe

    jellytoe Member

    I am wanting to query the database where location = "specific city" and return a list of e-mails. Can anyone help with how to write the query? I'm a clueless SQL user.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Try this:
    Code:
    SELECT u.email
    FROM xf_user as u
    LEFT JOIN xf_user_profile AS p ON
    (p.user_id = u.user_id)
    WHERE p.location = 'London'
    Change 'London' to suit.
     
  3. jellytoe

    jellytoe Member

    Works great thanks.
     

Share This Page