0

I have a MySQL table with four columns. DataID is PRIMARY KEY

+---------+----------+---------+----------+
| DataID  | time     | type    | value    |
+---------+----------+---------+----------+
| 1       | t1       | a       | 1        |
| 2       | t1       | b       | 2        |
| 3       | t1       | c       | 3        |
| 4       | t2       | a       | 4        |
| 5       | t2       | b       | 5        |
| 6       | t2       | c       | 6        |
+---------+----------+---------+----------+

I want to rearrange the table by putting it in a VIEW and with the format as followed:

+----------+---------+----------+----------+
| time     | type a  | type b   | type c   |
+----------+---------+----------+----------+
| t1       | 1       | 2        | 3        |
| t2       | 4       | 5        | 6        |
+----------+---------+----------+----------+

There are a lot of values in the table. How do I write the correct SELECT statement to rearrange the table? I'm really new to MySQL and it is my first try with VIEW. Any help is appreciated.

0 Answers0