嗨,我想连接两个 sql 查询结果:
select nome
from prodotto as nome
inner join prodotto_presente
on codice_prodotto=codice
and quantità_prodotto<soglia_minima
and codice_reparto=125
and cod_supermercato=2345
union
select stima_tempo_consegna
from fornitore as strima
inner join supermercato_ordine
on codicefornit=codice
and codice_supermercato=2345
inner join prodotto_presente
on odotto_presente.codice_prodotto = supermercato_ordine.codice_prodotto
and quantità_prodotto<soglia_minima
inner join prodotto
on prodotto_presente.codice_prodotto=prodotto.codice
and codice_reparto=125;
一个表中的输出是两个查询的并集,但我想要两个表输出。 我想要这个输出:
Nome strima
---------------
ssss yyyyy
uuuu oooo
我是怎么做的?
答案 0 :(得分:0)
查看您的示例似乎需要两个查询之间的连接
select t1.nome, t2.strima
from (
select codice, nome
from prodotto
inner join prodotto_presente on codice_prodotto=codice and quantità_prodotto<soglia_minima
and codice_reparto=125
and cod_supermercato=2345 ) t1
INNER JOIN (
select codicestima_tempo_consegna strima
from fornitore
inner join supermercato_ordine on codicefornit=codice
and codice_supermercato=2345
inner join prodotto_presente on prodotto_presente.codice_prodotto=supermercato_ordine.codice_prodotto
and quantità_prodotto<soglia_minima
inner join prodotto on prodotto_presente.codice_prodotto=prodotto.codice
and codice_reparto=125
) t2 on t1.codice = t2.codice