I want to make a view in MySQL that will be generated from 3 tables.
Please see the following tables.
All I want to do is to create a view, using col:name of table:ItemList as the labels of the columns of the new view.
How can I achieve this using SQL?
Thank you a lot in advance.
table: ItemList ,this changes so frequently
+----+-------------+
| id | name |
+----+-------------+
| 1 | Apple |
| 2 | Orange |
| 3 | Banana |
| 4 | Kiwi |
| 5 | Mango |
+----+-------------+
table: UserList
+----+-------------+
| id | name |
+----+-------------+
| 1 | John |
| 2 | Mary |
| 3 | James |
+----+-------------+
table: OrderList
+----+------+------+-----+
| id | User | Item | qty |
+----+------+------+-----+
| 1 | 1 | 4 | 1 |
| 2 | 1 | 2 | 2 |
| 3 | 2 | 1 | 4 |
| 4 | 1 | 3 | 3 |
| 5 | 3 | 5 | 1 |
| 6 | 2 | 2 | 2 |
+----+------+------+-----+
view that I want to create
+-------+-------+--------+--------+------+-------+
| User | Apple | Orange | Banana | Kiwi | Mango |
+-------+-------+--------+--------+------+-------+
| John | | 2 | 3 | 1 | |
| Mary | 4 | 2 | | | |
| James | | | | | 1 |
+-------+-------+--------+--------+------+-------+