0

i have a table like this

select * from table1;
----------------------------------
id|time     |date   |Status  |
1 |07:30:00 |2019-06-19 | 0      |
1 |11:30:00 |2019-06-19 | 1      |
1 |13:00:00 |2019-06-19 | 2      |
1 |16:30:00 |2019-06-19 | 3      |
2 |08:10:00 |2019-06-19 | 0      |
2 |12:03:00 |2019-06-19 | 1      |
2 |13:01:00 |2019-06-19 | 2      |
2 |16:15:00 |2019-06-19 | 3      |

how to query so get result like this

-------------------------------------------------------------------------------------------------------
id|Date       | status=0 as Chekin | status=1 as Breakout| satus=2 as Breakin  | status=3  as Chekout |
1 |2019-06-19 | 07:30:00           | 11:30:00            | 13:00:00            | 16:30:00             |
2 |2019-06-19 | 08:10:00           | 12:03:00            | 13:01:00            | 16:15:00             |
3 |next record| next record        | next record         | next record         | next record          |
4 |next record| next record        | next record         | next record         | next record          |
5 |next record| next record        | next record         | next record         | next record          |
6 |next record| next record        | next record         | next record         | next record          |
7 |next record| next record        | next record         | next record         | next record          |
8 |next record| next record        | next record         | next record         | next record          |
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Hip Hura
  • 143
  • 8
  • Of if you need to have it Dynamic and automatic works when you add more status see [Dynamic pivot MySQL](https://stackoverflow.com/questions/25409022/dynamic-pivot-mysql) – Raymond Nijland Jun 19 '19 at 11:09
  • Consider storing date and time as a single entity, and consider handling issues of data display in application code. – Strawberry Jun 19 '19 at 11:21
  • mr Raymond Nijland, thats worked, i want to learn about Dynamic Pivot, thanks alot – Hip Hura Jun 19 '19 at 11:31

0 Answers0