select 如何从多个表中获取唯一的最小值

How select unique minimum value from more tables

我有以下问题。

在MySQL中我有两个表:

Table A
---------------------------
| idOffer| price
| 4      | 20
| 4      | 30
| 5      | 15
| 5      | 18
| 6      | 6
| 4      | 9
--------------------------------------------------

Table B
---------------------------
| idOffer| price
| 4      | 60
| 4      | 70
| 5      | 10
| 5      | 8
| 6      | 90
| 6      | 100
--------------------------------------------------

是否有可能的查询,return 结果类似于

| idOffer| price
| 4      | 20
| 5      | 8
| 6      | 6

这是一个带有 union all 语句的选项:

select idoffer, min(price)
from (
    select idoffer, price from tablea
    union all
    select idoffer, price from tableb
) t
group by idoffer