我有以下查询
SELECT *
FROM users
WHERE id NOT IN (
SELECT user_id
FROM `counter`
WHERE DATE_SUB( CURDATE( ) , INTERVAL 14 DAY ) <= created
)
AND id IN (
SELECT user_id
FROM coupon_used
)
AND id IN (
SELECT user_id
FROM accounts
)
我需要将 where 子句放在 coupon_used 表中,如果 user id IN coupon used 表中代码 ='xyz'。我确实喜欢这个
id IN (
SELECT user_id, code
FROM coupon_used WHERE code ='xyz'
)
但告诉我一个错误:
操作数应包含 1 列。