4
I have 2 select which are basically identical, changing only 1 table. I’m trying to put the 2 together in a single select, but I’m not getting it.
Follows the select:
SELECT DISTINCT
a.id,
a.unidade,
a.posicao,
a.nome,
a.peso
FROM
produtos a,
produtos_pedidos b
WHERE
a.id = b.id_produto
and b.id_pedido IN (1,2)
ORDER BY a.nome
Select 2:
SELECT DISTINCT
a.id,
a.unidade,
a.posicao,
a.nome,
a.peso
FROM
produtos a,
pedidos_barganha b
WHERE
a.id = b.id_produto
and b.id_pedido IN (1,2)
ORDER BY a.nome
Does anyone know how I can put the two together?
Gave the following error #1250 - Table 'a' of one of the Selects cannot be used in field list
– Hugo Borges
@Hugoborges edited the answer, you could test?
– Jeferson Almeida
now this way #1250 - Table 'p' of one of the Selects cannot be used in field list
– Hugo Borges
found the bug, just change the ' ORDER BY name'
– Hugo Borges
@Hugoborges fix this and added one more information at the end
– Jeferson Almeida