we create a scheduler system and have a couple of situations when we try to get some notes from a table for display. We looked at other answers, and none of them correspond to this problem.
The order table contains a numerical reference to both the clientโs note (if any) and the stylistโs note (if any).
The notes table stores both client notes and stylists, each of which is indexed by a unique numerical index
We have our request when we just want to read in client notes:
SELECT bookings.bookingID, UNIX_TIMESTAMP(bookings.startDate) AS start_date, UNIX_TIMESTAMP(bookings.endDate) as end_date, clientDetails.firstName, clientDetails.lastName, clientDetails.phone1, clientDetails.phone2, clientDetails.email, services.name, services.serviceID, cNotes.note as client_notes, sNotes.note as stylist_note
FROM bookings
LEFT JOIN clientDetails ON bookings.clientID = clientDetails.clientID
LEFT JOIN services ON bookings.serviceID = services.serviceID
LEFT JOIN notes ON bookings.clientNotes = notes.notesID
WHERE bookings.startDate >= '" . $start_date . "' AND bookings.endDate <= '" . $end_date . "' AND bookings.stylistID = '" . $stylist_id . "'
ORDER BY bookings.startDate ASC;
Using this logic, we can access cient notes from an array of results in php just like: $ results_array ['note']
, , - , , $results_array ['stylist_note'].
, :
LEFT JOIN notes ON bookings.stylistNotes = notes.notesID
.
.