我有4张桌子。这是我的代码
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
我如何在desc中订购?非常感谢:))
答案 0 :(得分:0)
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
答案 1 :(得分:0)
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
这就是你要问的问题,但这个专栏的来源是什么?
答案 2 :(得分:0)
根据您的评论,您只需添加ORDER BY DESC [COLUMN]
。
这应该可以解决你的问题。
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
我建议你用更多的mnemotechnic方式命名你的变量,我会更容易分析,说SELECT * FROM reservation AS r
答案 3 :(得分:0)
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
但请确保