Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get multiple rows from mysql separated by a value (ie assigned_day) JSON
    primarykey
    data
    text
    <pre> lesson_id subject teacher classes week assigned_day assigned_period assigned_room 249700 INFDTB03 HENML INF3B ABCDEFG 4 3 A.0.30 249700 INFDTB03 HENML INF3B ABCDEFG 4 4 A.0.30 251500 INFPROGX BLAJF INF3B ABCDEFGH 1 5 A.3.20 251500 INFPROGX BLAJF INF3B ABCDEFGH 1 6 A.3.20 71600800 CMIBSK13 SCHUER INF3B ABCDEFGH 4 2 C.1.04 71600900 INFUSA01 BRUSA INF3B ABCDEFGHIJ 4 5 K.1.22 71600900 INFUSA01 BRUSA INF3B ABCDEFGHIJ 4 6 K.1.22 71601200 CMIBSK08 TJAJY INF3B ABCDE 5 7 A.3.04 71601200 CMIBSK08 TJAJY INF3B ABCDE 5 8 A.3.04 71601200 CMIBSK08 TJAJY INF3B ABCDE 5 9 A.3.04 </pre> <p>I need to build a JSON-object out of it. In <strong>a DIFFERENT FORMAT than this one...</strong>: Every part has to be grouped by Assigned_day.</p> <pre> { "ExceptionId": "0", "ExceptionMessage": "", "Items": [ { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_day": "2", "assigned_period": "10", "assigned_room": "B.2.02" }, { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_day": "2", "assigned_period": "11", "assigned_room": "B.2.02" } ] } </pre> <p>I hope it is clear enough. What I get now is all the data together with every day separate. What i want is that every lesson is collected in a Assigned_Day.</p> <p>Is it possible to do that just with the mysql query. Because i'm using a Json_encode method to convert from mysql object to JSON-object.</p> <p>Like this:</p> <pre> { "ExceptionId": "0", "ExceptionMessage": "", "Items": [ { "0": [ { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_period": "10", "assigned_room": "B.2.02" }, { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_period": "11", "assigned_room": "B.2.02" } ], "1": [ { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_period": "10", "assigned_room": "B.2.02" }, { "lesson_id": "219700", "subject": "CMIBES01K", "teacher": "ERMYM", "classes": "AP", "week": "ABCDEFGHIJ", "assigned_period": "11", "assigned_room": "B.2.02" } ] } ] } </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload