signed

QiShunwang

“诚信为本、客户至上”

603. 连续空余座位-sql

2021/6/9 5:37:05   来源:

 

select distinct c1.seat_id 
from cinema as c1, cinema as c2
where c1.free = 1 
and c2.free = 1 
and (c1.seat_id = c2.seat_id +1 or c1.seat_id = c2.seat_id - 1)
order by seat_id;

select distinct c1.seat_id from cinema as c1, cinema as c2

where c1.free = 1 and c2.free = 1 and (c1.seat_id = c2.seat_id +1 or c1.seat_id = c2.seat_id - 1)

order by seat_id;