Skip to content
Advertisement

Update records in table from CTE results

I want to update the records in my table using CTE. And I’ve been trying with the insert function using CTE and it’s working. This is my query with the insert function:

How to change that with the update function?

i want to change to update function because when i use insert function,the previous data that already exists in DAILYDATA appear again

This is table DAILYDATA

TABLE DAILYDATA

This is table DAILYDATAWH

TABLE DAILYDATAWH

error

Advertisement

Answer

It seems to me that you want to update table after joining like below

Read the following post to have a better understanding

SQL Update after Joining Two Tables

Updated

You should use multiple CTE in a query like below

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement