开发者

Loops in MySQL alone

开发者 https://www.devze.com 2023-02-10 14:01 出处:网络
I\'d like to select from one table and use the results of that select to update another table, but only based on certain con开发者_运维知识库ditions.Is this possible with a 1-time SQL query?Yes it is.

I'd like to select from one table and use the results of that select to update another table, but only based on certain con开发者_运维知识库ditions. Is this possible with a 1-time SQL query?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消