I’m looking to do a single query to update a database. Here is some pseudocode:
UPDATE Table1 SET Table1.Value = (SELECT Value FROM Table2 WHERE Table2.Id==2) WHERE Table1.Id == 4
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will only work if your subquery
(SELECT Value FROM Table2 WHERE Table2.Id=2)only returns one value. Also replace the==with=in your subquery as I have.I believe updating it to what I have below would make it work no matter what:
(SELECT Top (1) Value FROM Table2 WHERE Table2.Id=2)