Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The target table of the UPDATE is not updatable

Tags:

sql

mysql

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?

like image 403
user3014966 Avatar asked Dec 10 '13 15:12

user3014966


People also ask

Which statement is not valid for an update table view?

If a view is not updatable, statements such UPDATE , DELETE , and INSERT are illegal and are rejected.

What Makes a view not updatable?

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.

Which views are not updatable in SQL?

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.

Under what conditions are views updatable?

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.


1 Answers

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

like image 136
Mad Dog Tannen Avatar answered Oct 07 '22 12:10

Mad Dog Tannen