The problem is the use of the logical operator AND
unduly:
ORDER BY `transaction_DATE` AND `transaction_HOUR` DESC LIMIT 8
^^^
If you want to sort by more than one column, separate by comma, always starting from the order with more priority to the smallest:
ORDER BY expressao1, expressao2, expressao3
Applying to your case:
SELECT * FROM `website_transactions` ORDER BY `transaction_DATE`, `transaction_HOUR` LIMIT 8
If you want to reverse the order, you need to put the DESC
(Descending) in all columns as applicable. Example:
nome ASC, transaction_DATE DESC, transaction_HOUR DESC
In this example, the name would be in alphabetical order (crescent), but the date in descending order and the time also (the word ASC is dispensable, I put only to illustrate)
Remembering that there are formats in Mysql that store date and time, but the convenience of using or not these formats depends a lot on how you will use and index the data.
ORDER BY
transaction_DATE
,transaction_HOUR
– Motta
The problem is the misuse of AND in values that are not logical. If you want to sort by more than one column, separate with comma.
– Bacco