开发者

Loops in MySQL alone

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜