I need to run this query :
UPDATE TempRH T
JOIN (
SELECT offices_id,MAX(Poids)AS Poids
FROM TempRH
GROUP BY
offices_id
)T1
ON T1.offices_id=T.offices_id
SET T1.Poids=0
but on execution it gives an error:
#1288-The target table T1 of the UPDATE is not updatable.
Any solutions?
If a view is not updatable, statements such UPDATE , DELETE , and INSERT are illegal and are rejected.
For a view to be updatable, there must be a one-to-one relationship between the rows in the view and the rows in the underlying table. There are also certain other constructs that make a view nonupdatable.
The SQL UPDATE VIEW command can be used to modify the data of a view. All views are not updatable. So, UPDATE command is not applicable to all views. An updatable view is one which allows performing a UPDATE command on itself without affecting any other table.
A column of a view is updatable when all of the following rules are true: The view is deletable. The column resolves to a column of a table (not using a dereference operation) and the READ ONLY option is not specified.
Seems to me a small change would fix this?
UPDATE TempRH T
JOIN (
SELECT offices_id,MAX(Poids)AS Poids
FROM TempRH
GROUP BY
offices_id
)T1
ON T1.offices_id=T.offices_id
SET T.Poids=0
Change T1.Poids
to T.Poids
. So you SET
a value on the TABLE
you want to UPDATE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With