mysql 是否显示记录中每个子查询结果?

g6ll5ycj  于 12个月前  发布在  Mysql
关注(0)|答案(1)|浏览(133)

我有两个子查询,每一个都有2列,但具有不同的值。
如何在一个结果中显示这种差异。
Q1:

select
city
,length(city) as le
from station
where length(city) in 
    (select min(length(city)) from station)
order by length(city) asc , city asc 
limit 1

字符串
产出:
| 列A|色谱柱B|
| --|--|
| HHH| 3 |
Q2:

select
city
,length(city) as le
from station
where length(city) in 
    (select min(length(city)) from station)
order by length(city) asc , city asc 
limit 1


产出:
| 列A|色谱柱B|
| --|--|
| 比约格| 4 |
所需产量
| 列A|色谱柱B|
| --|--|
| HHH| 3 |
| 比约格| 4 |
谢谢
只是问题和需要支持

ykejflvf

ykejflvf1#

(
select
city
,length(city) as le
from station
where length(city) in 
    (select min(length(city)) from station)
order by length(city) asc , city asc 
limit 1
)
UNION ALL
(
select
city
,length(city) as le
from station
where length(city) in 
    (select min(length(city)) from station)
order by length(city) asc , city asc 
limit 1
)

字符串

相关问题