SQL update query syntax error

1

When I run the following update query, a syntax error occurs before or within from:

UPDATE Artigos 
SET totale = entradas.sent
FROM Artigos INNER JOIN (SELECT cod_artigo, Sum([quantidade_ent]) AS sent FROM entradas GROUP BY cod_artigo)
ON Artigos.cod_artigo = Entradas.cod_artigo;

I'm using access

Error message:

  

Syntax error (missing operator) in the query expression "tmp.sent FROM Articles INNER JOIN (SELECT cod_argum, Sum ([as_quotation]) AS sent FROM GROUP BY entries cod_article) as tmp ON Articles.cod_article = tmp. cod_artigo; "

    
asked by anonymous 07.07.2016 / 17:38

2 answers

0

I believe putting an Alias for the subquery will solve it.

UPDATE Artigos 
SET Artigos.totale = tmp.sent
FROM Artigos INNER JOIN (SELECT cod_artigo, Sum([quantidade_ent]) AS sent FROM entradas GROUP BY cod_artigo) as tmp
ON Artigos.cod_artigo = tmp.cod_artigo;    
    
07.07.2016 / 19:02
0

Friend, if I understood your proposal well, the following SQL solves your problem:

UPDATE artigos
SET    totale = tmp.sent
FROM   (SELECT  cod_artigo,
            SUM(quantidade_ent) AS sent
   FROM     entradas
   GROUP BY cod_artigo
   )
   tmp
WHERE  tmp.cod_artigo = tmp.cod_artigo;
    
11.07.2016 / 18:39