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.
精彩评论