0

I have two tables. One with login information logins which holds password column and one with emails emails which holds email column and loginID column. I would like to use parameters on both tables. I would like to find row in emails where email=? and then take the corresponding login id inside that row and match this to a row in logins table. I would then like to match the password to the row in logins. A double separated where statement from two tables.

Something along the lines of:

$prepareTables=$listersDatabase->prepare("select*from emails where email=? left join logins on emails.loginID=logins.ID where password=?");
$prepareTables->execute(array("[email protected]","password123"));

Any help is appriciated

1
  • what's the problem, Your code seems to be correct. Can you tell us a little bit more? Commented Dec 29, 2015 at 10:41

1 Answer 1

1

Try this:

SELECT * 
FROM
    emails 
INNER JOIN logins 
ON emails.loginID=logins.ID 
WHERE 
    emails.email=?
AND
    password=?

I used INNER JOIN instead of LEFT JOIN as you have this table inside a WHERE condition anyway. You must put all your conditions inside one WHERE clause.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.