php mysql asc/desc bestellen

TABELLE:

**timeslot**:
----------
id_timeslot   times
1             09:00
2             09:30
3             10:00
4             10:30
5             11:00

**bookslot**
id   id_timeslot     date        b_ref
-------------------------------------------
1    2               2010-02-22  001 
2    3               2010-02-22  001
3    4               2010-02-22  001
4    5               2010-02-22  001
5    2               2010-02-25  002
6    3               2010-02-27  003
7    4               2010-02-27  003
8    5               2010-02-27  003

PHP

$q = $mysqli->query("SELECT * FROM bookslot  
LEFT JOIN timeslot ON bookslot.id_timeslot = timeslot.id_timeslot   
WHERE bookslot.status = 1 
GROUP BY bookslot.b_ref  
ORDER BY bookslot.date ASC, bookslot.id_timeslot ASC LIMIT 20");

HTML-ERGEBNIS:

DATE         TIMES  
2010-02-22   10:30
2010-02-25   09:30
2010-02-27   11:00

jemand bemerken, dass auf der Tabelle Ergebnis. die Zeiten falsch um?
ich änderte ein anderer Weg, Runde mit ASC /DESC und noch mal mit der letzten id_timeslot?

ERWARTETE ERGEBNIS:

DATE         TIMES  
2010-02-22   09:30
2010-02-25   09:30
2010-02-27   10:00
Es ist korrekt, soweit ich sehen kann, 2010-02-22 10:30 kommt bevor 2010-02-25 09:30 und 2010-02-27 11:00.
Naja, ich kann nicht finden, was Sie zu erreichen versuchen. Aber 2010-02-27 können nicht zugeordnet werden 10:00 weil seine timeid ist 5 die 11:00 ...
Sie sind Beispiel fehlt auch die status-Spalte in der bookslot Tisch, obwohl Sie es zu benutzen in Ihrem WHERE-Klausel. Könnte das etwas zu tun mit es?

InformationsquelleAutor tonoslfx | 2011-02-22

Schreibe einen Kommentar