Possible Duplicate:
Combine Multiple child rows into one row MYSQL
I have following table,
count | inventory_id | resource_id | id
---------+-----------+----------------------
10 | 1 | 1 | 1
20 | 2 | 1 | 2
30 | 1 | 2 | 3
40 | 2 | 2 | 4
I want to merge rows where resource_id is equal and also want to give alias for each count according to inventory_id. I need to give alias "Resource 1" for count where inventory_id =1 and "Resource 2" where inventory_id=2
output needed:
Resource 1| Resource 2 |resource_id
---------+-----------+-----------------
10 | 20 | 1
30 | 40 | 2