using ORDER_BY on two columns. the first being a date
Posted: Wed May 20, 2009 4:49 am
Hi
What I am trying to do is get my results to return in date order firstly and then by alphabetical order.
I thought I'd be able to do this by adding 'ORDER BY b.arrival_date ASC, c.name ASC' to my query. And that does put some in the order I wish but not all.
I then thought that it must have something to do with the date's that are stored in mysql under the arrival_date coloumn, but they are exactly the same ie have no hours, seconds attached.
Any ideas welcome .
Thanks
What I am trying to do is get my results to return in date order firstly and then by alphabetical order.
I thought I'd be able to do this by adding 'ORDER BY b.arrival_date ASC, c.name ASC' to my query. And that does put some in the order I wish but not all.
I then thought that it must have something to do with the date's that are stored in mysql under the arrival_date coloumn, but they are exactly the same ie have no hours, seconds attached.
Any ideas welcome .
Code: Select all
$query = "SELECT b.arrival_date, b.departure_date, c.name, b.rid FROM booking_admin AS ba LEFT JOIN bookings AS b ON ba.booking_id = b.booking_id LEFT JOIN customers AS c ON b.cust_id = c.cust_id WHERE b.arrival_date >= '$date_commencing_original' AND b.arrival_date <= '$date_ending_original' AND ba.status != 'cancelled' AND ba.status != 'denied' AND ba.status != 'historic' ORDER BY b.arrival_date ASC, c.name ASC ";