Using Union


  • 0
    P

    Union takes care of duplicates

    select c1.seat_id from cinema c1, cinema c2
    where c1.seat_id+1 = c2.seat_id 
    and c1.free = true 
    and c2.free = true
    union 
    select c1.seat_id from cinema c1, cinema c2
    where c1.seat_id = c2.seat_id+1
    and c1.free = true 
    and c2.free = true
    order by 1
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.