select *
from coupon_use_log
where coupon_id = 4139
and user_id = 31165;
+----+--------+-------------+-------+---------+---------------------+----------+
|id |order_id|order_list_id|user_id|coupon_id|created_at |deleted_at|
+----+--------+-------------+-------+---------+---------------------+----------+
|1716|13803 |14526 |31165 |4139 |2019-11-22 19:51:14.0|NULL |
|1717|13803 |14526 |31165 |4139 |2019-11-22 19:52:26.0|NULL |
|1718|13803 |14526 |31165 |4139 |2019-11-22 19:52:27.0|NULL |
|1719|13803 |14526 |31165 |4139 |2019-11-22 19:52:28.0|NULL |
+----+--------+-------------+-------+---------+---------------------+----------+
SELECT *
FROM coupon_use_log
WHERE deleted_at is null
and user_id = 31165
group by order_id;
+----+--------+-------------+-------+---------+---------------------+----------+
|id |order_id|order_list_id|user_id|coupon_id|created_at |deleted_at|
+----+--------+-------------+-------+---------+---------------------+----------+
|1716|13803 |14526 |31165 |4139 |2019-11-22 19:51:14.0|NULL |
+----+--------+-------------+-------+---------+---------------------+----------+
첫번째 조회 테이블에서 deleted_at 값이 모두 not null 이어야
두번째 쿼리에서 조회가 안됨
첫번째 조회 테이블에서 하나라도 null 이면
두번째 쿼리 조회 시 조회 됨