Problem with select UNION ALL mysql

0

I mounted the following select in MYSQL:

                SELECT 
            id_produto, 
            SUM(qtd) as qtd 
        FROM 
         (
             SELECT 
                id, 
                id_produto, 
                qtd 
            FROM 
                produtos_pedidos 
            WHERE
                id_pedido = '1'
       UNION ALL
            SELECT 
                id, 
                id_produto, 
                qtd 
            FROM 
                pedidos_barganha
            WHERE
                id_pedido = '1'
                and tipo = 'b'
        ) res
        GROUP BY 
            id_produto 

I squeeze it into PHPMYADMIN and it works, however it's giving some editor errors, and I do not know what it can be.

I'll post the photos here:

    
asked by anonymous 09.09.2016 / 18:33

1 answer

1

I recommend updating the editor. This syntax is valid and you yourself said that it works if run in PHPMyAdmin. I also suggest trying to run directly through the MySQL client. It may be that the editor you are using does not parse the queries properly, so the editor is wrong, but for MySQL it is not.

To handle database, I recommend Squirrel SQL.

    
09.09.2016 / 20:34