MySQL: Update all rows in a table matching results of another query

后端 未结 3 1745
一个人的身影
一个人的身影 2021-02-04 05:56

I\'ve written a query returning rows associating Customers and Salespeoeple.

Note that the query joins several database tables. And note that not all c

3条回答
  •  鱼传尺愫
    2021-02-04 06:45

    You can create a view to make your UPDATE statement simple. The view should contain your query (in your case the query that associates customers and salespeople). Then update your table (invoices in your case) like this:

    update TableToUpdate ttu, MyView mv
    set ttu.column = mv.column
    where ttu.key = mv.key
    

提交回复
热议问题