我有2個表 - reservation
:返回行,如果值不存在
id | some_other_column
----+------------------
1 | value
2 | value
3 | value
而第二個表 - reservation_log
:
id | reservation_id | change_type
----+----------------+-------------
1 | 1 | create
2 | 2 | create
3 | 3 | create
4 | 1 | cancel
5 | 2 | cancel
,我需要選擇不僅沒有取消的預訂(它是在這個例子中只有ID 3)。 我可以很容易地選擇取消與簡單的WHERE change_type = cancel
條件,但我很努力與NOT取消,因爲簡單的WHERE
不起作用。
指不等於文檔:http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_not-equal – Ric
這些意見不正確的,因爲1和2有類型!=取消。 – Barmar
如果我使用不等於'WHERE change_type!='取消'它打印所有保留,這是錯誤的,因爲只有保留與ID 3沒有取消 – Madr