Return row only if value doesn't exist

后端 未结 2 1900
终归单人心
终归单人心 2020-11-21 06:11

I have 2 tables - reservation:

   id  | some_other_column
   ----+------------------
   1   | value
   2   | value
   3   | value
2条回答
  •  再見小時候
    2020-11-21 06:41

    Just for completeness (and I honestly believe it fits better), I encourage you to use a simple NOT EXISTS.

    SELECT * FROM reservation R
    WHERE NOT EXISTS (
      SELECT 1 FROM reservation_log
      WHERE reservation_id = R.id
        AND change_type = 'cancel'
    );
    

提交回复
热议问题