我有两个问题
SELECT
IF(t_booking_details.status = 1, t_room.code, (IF (t_stay_info.room IS null , t_room.code,null))) as room
FROM t_stay_info
INNER JOIN t_booking_details
ON t_stay_info.code = t_booking_details.stayInfo
RIGHT JOIN t_room
ON t_room.code = t_stay_info.room
INNER JOIN t_room_type
ON t_room_type.code = t_room.roomType
WHERE t_room_type.name = "Deluxe Double"
结果:
+-------+ | room | +-------+ | NULL | | code2 | | code3 | | code4 | +-------+
SELECT
IF(t_reservation.`status` = 1, t_room.code, (IF (t_stay_info.room IS null , t_room.code,null))) as room
FROM t_stay_info
INNER JOIN t_reservation
ON t_stay_info.code = t_reservation.stayInfo
RIGHT JOIN t_room
ON t_room.code = t_stay_info.room
INNER JOIN t_room_type
ON t_room_type.code = t_room.roomType
WHERE t_room_type.name = "Deluxe Double"
结果
+-------+ | room | +-------+ | code1 | | code2 | | code3 | | NULL | +-------+
如何合并结果以便获得:
+-------+ | room | +-------+ | NULL | | code2 | | code3 | | NULL | +-------+