user3616687
user3616687

Reputation: 94

check username in table 1 and return data from table 2

How can i check a password matching a username and returning data from other table.

i have 2 tables. Users and Lists. In the lists table i have a column for email and some more in the users table i have a column for email and password. how can i check the username and password and match the corresponding values from the lists table?

What is tried were some joins but my problem is i am running it on a php file.. So it needs to be run from there as well.

this is my query to check in 1 database.

$sql = "SELECT * 
        FROM users 
        WHERE Email = '$email' 
            AND Password = '$password'"

i think is should be something like

$sql = "SELECT colomn1
              ,colomn2
              ,colomn3 
        FROM list 
        WHERE email = $email 
            and password = $password 
        LEFT OUTER JOIN lists.email 
            on users.email.

tables http://www.project-hr.nl/tables.png

Upvotes: 0

Views: 175

Answers (1)

iMakeWebsites
iMakeWebsites

Reputation: 587

how about this:

$sql= "SELECT 
           colomn1, colomn2, colomn3
       FROM
           list
               LEFT JOIN
           users USING (email)
       WHERE
           list.email = '$email'
               AND list.password = '$passwhere'"

Upvotes: 1

Related Questions