SELECT * FROM reservation AS t1 INNER JOIN guest AS t2
ON t1.guest_id = t2.guest_id
INNER JOIN room AS t3
ON t1.room_id = t3.room_id
INNER JOIN room_type AS t4
ON t3.room_type_id = t4.room_type_id
order by t1.guest_id desc
SELECT * FROM reservation AS t1 INNER JOIN guest AS t2
ON t1.guest_id = t2.guest_id
INNER JOIN room AS t3
ON t1.room_id = t3.room_id
INNER JOIN room_type AS t4
ON t3.room_type_id = t4.room_type_id
ORDER BY t1.reservation_datetime DESC
This would be what you're asking but where does this column come from?
According to your comments, you just need to add the ORDER BY DESC [COLUMN]
.
That should fix your issue.
SELECT * FROM reservation AS t1
INNER JOIN guest AS t2
ON t1.guest_id = t2.guest_id
INNER JOIN room AS t3
ON t1.room_id = t3.room_id
INNER JOIN room_type AS t4
ON t3.room_type_id = t4.room_type_id
ORDER BY t1.reservation_datetime DESC
I would recommend that you name your variables in a more mnemotechnic way, I will be much easier to analyze, saying SELECT * FROM reservation AS r
SELECT * FROM reservation AS t1
INNER JOIN guest AS t2 ON t1.guest_id = t2.guest_id
INNER JOIN room AS t3 ON t1.room_id = t3.room_id
INNER JOIN room_type AS t4 ON t3.room_type_id = t4.room_type_id
ORDER BY t1.reservation_datetime DESC
but make sure
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.