how to convert column to row in mysql(column having the same value)

SubhashiniS

I have got below format using join query

status | vacancy | selected
opening|  10     |   5
closed |  10     |   2

but I want to below format, how to get it using 'mysql' query

status  |  selected
vacancy |  10
opening |  5
closed  |  2
Augusto

You can select the vacancy and make a union with your other select.

select 'vacancy', h.vacancy from hotel h where h.id = 1 
 union all
select status, selected from room where hotel_id = 1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to identify the row numbers having same value for all column in R?

pandas: delete a row having same value of a column as in previous raw

How to copy the previous row value of the same column?

How to convert rows that contain same value for one column but different for other columns into one single row using R?

SQL - How to select a row having a column with max value (+ group by)

Copy values of a row in to column having same key

how to convert every row as column and value before colon into column name

How to Count a value in a column if another column with the same row equals to something?

How to move some value in a column to different column on the same row

How to insert a row having only one column different than the other row in the same table?

Reference another cell in the same row having calculated the minimum value in a datatable column

How to calculate a value row that is based on the previous value in the same column (in R)?

How to replace value in pandas with value in the same row but in a different column

How to convert column into row?

how to convert a dataframe containing 1's and 0's and add a new column to the same dataframe that represents the hex value of entire row in python

How to find the row value of other column(column2), if my row value isin same column(column1) in other row

select groups having same value in a column

how to use previous row value as well as values in other column in same row to compute value of a column in pandas

Update column value based on row value in the same row, row by row

How to get column name from table from 2 rows of same table having same value?

How to convert column values to single row value in postgresql

How to group rows with the same column value into one row in C?

How to delete a row in a dataframe based on a column event with consecutive same value

How to group in a row values of the same value in a column with R?

How can I copy the value of a previous row, on the same column in a DataFrame?

How to calculate the value in different row but same column and group it in sql

how to use boolean indexing to find value on same row but different column

Pandas:How to fill in value from the same column but different row

How to extract the value corresponding to same head row and head column of a file?