MySQL Forums
Forum List  »  General

Query Error
Posted by: ignacio rivas
Date: August 31, 2016 06:13PM

I have an error when i try to run an UPDATE on a table, but i've been searching a lot and keep getting the same error, i hope someone can help me out here.

The error is:

Error Code: 1093
You can't specify target table 'trafico' for update in FROM clause

And the query is something like this:

UPDATE
table1.trafico
SET
table1.trafico.RDocumentos=(SELECT
RD.Folio
FROM table2.vt_rdocumentos RD
INNER JOIN table2.vt_rdocumentosdeta RDD ON RD.ID=RDD.RDocumentos
INNER JOIN table2.vt_pedimentos P ON RDD.PedimentoID=P.ID
INNER JOIN table2.vt_clientes C ON C.ID=P.Cliente
LEFT JOIN table1.trafico T ON T.RDocumentos=RD.Folio
WHERE
RD.Placas='M3'
AND C.Numero='GM064'
AND RD.FechaEmision=CURRENT_DATE AND NOT EXISTS (SELECT table1.trafico.RDocumentos FROM table1.trafico WHERE table1.trafico.RDocumentos=RD.Folio)
GROUP BY RD.Folio)
, table1.trafico.PapelesDespacho=1
, table1.trafico.HorapapelDesp=CONCAT(CURRENT_DATE,' ',CURRENT_TIME)
WHERE
table1.trafico.ID='76' AND
DATE(table1.trafico.HorafacturaRec)=CURRENT_DATE AND
table1.trafico.PapelesDespacho=0 AND
table1.trafico.Despachado=0 AND
table1.trafico.Rojo=0 AND
table1.trafico.Rojo2=0 AND
table1.trafico.Libre=0

Someone HELP ME PLEASE!!!

Options: ReplyQuote


Subject
Written By
Posted
Query Error
August 31, 2016 06:13PM
September 01, 2016 10:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.