0

I'd like to select from one table and use the results of that select to update another table, but only based on certain conditions. Is this possible with a 1-time SQL query?

2
  • 3
    Do you want us to just say "yes" in an answer??? Perhaps you'd like to flesh out your question a bit more. Commented Feb 11, 2011 at 20:51
  • 1
    Yes it's possible. Can you give a concrete example? Otherwise you'll probably just get a link to the manual which some contains examples. Commented Feb 11, 2011 at 20:51

1 Answer 1

2

Yes it is.

UPDATE
  tableToUpdate AS ttu
[LEFT|RIGHT|INNER] JOIN
  otherTable AS ot
ON 
  joinCondition
SET
  ttu.field = ot.field
WHERE
  conditionsToBeMet

AS otherTable you can just use the SELECT query that you use to fetch your resultset.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.