user3434701
user3434701

Reputation: 29

UPDATE using SELECT as WHERE

I want to run an Update where the WHERE statement consists of 2 SELECTS, is this at all close to how you do that?

UPDATE Requests SET Response=1 WHERE 
sender=SELECT userID FROM Users WHERE Username=?) and 
Reciever = SELECT userID FROM Users WHERE Username=?

Thank!

Upvotes: 1

Views: 62

Answers (1)

Thorsten Kettner
Thorsten Kettner

Reputation: 95101

You're missing parentheses, that's all.

UPDATE Requests SET Response=1 WHERE 
sender = (SELECT userID FROM Users WHERE Username=?) and 
receiver = (SELECT userID FROM Users WHERE Username=?);

Upvotes: 1

Related Questions