HELP! I'm trying to update a table and send error

1

Try to update the score field in my dashboard but send me an error:

  

code: 1093 You can not specify target table 'partitioned' for update in   FROM clause

I leave my sentence

use noble;
update dpartida 
   set score=1 
   where idpartida=
      (select p.idpartida from dpartida p 
       inner join dpersona m on p.idpartida=m.idpartida 
       inner join musuario u on m.idpersona = u.idpersona where u.nomusuario="qwe");

Please help me.

    
asked by Estefania 22.05.2017 в 00:47
source

1 answer

2

In MySQL , you can not reference the table that is being modified ( insert , update or delete ) within a subquery.

To avoid this error, you can force to create a temporary table by making the subquery like this:

update dpartida set score=1 where idpartida=
select p.idpartida from (select * from dpartida) p inner join ...

Anyway in the case of your query I think it's easier to do it with the join directly in the UPDATE :

UPDATE dpartida p
INNER JOIN dpersona m ON p.idpartida = m.idpartida 
INNER JOIN musuario u ON m.idpersona = u.idpersona 
SET p.score = 1
WHERE u.nomusuario = "qwe"
    
answered by 22.05.2017 / 01:17
source