I've the following table:
tb_item
id_item | item_name | price
----------------------------
1 | item1 | 2000
2 | item2 | 3000
3 | item3 | 4000
and
tb_value
id_value | id_item | value_type | value
----------------------------------------
1 | 1 | bedroom | 2
2 | 1 | bathroom | 1
3 | 2 | bedroom | 3
4 | 2 | bathroom | 1
5 | 3 | bedroom | 4
6 | 3 | bathroom | 2
I would like to get an output like this:
item_name | price | bedroom | bathroom
---------------------------------------
item1 | 2000 | 2 | 1
item2 | 3000 | 3 | 1
item3 | 4000 | 4 | 2
I'm using PostgreSQL; what query can be used to get this output? I'm using PHP too; is there a PHP function that can do this?