我使用连接查询获得以下格式
status | vacancy | selected
opening| 10 | 5
closed | 10 | 2
但是我想要以下格式,如何使用' mysql'查询
status | selected
vacancy | 10
opening | 5
closed | 2
答案 0 :(得分:-1)
您可以选择空缺并与其他选择结合。
select 'vacancy', h.vacancy from hotel h where h.id = 1
union all
select status, selected from room where hotel_id = 1