I wrote following sql query
SELECT clicks.offer_id, clicks.offer_name, clicks.country, clicks.device_type, clicks.os_name, conversions.name , clicks.ip_address as Session, conversions.conversion_ip as Conversion, conversions.currency as Currency , conversions.payout as Payout FROM clicks JOIN users ON clicks.affiliate_id = users.id LEFT JOIN conversions ON clicks.transaction_id = conversions.click_transaction_id WHERE clicks.affiliate_id = '2' AND conversions.status = ('approved' or 'pending') AND date(clicks.created_at) BETWEEN '2021-11-08' AND '2021-12-07'
in where condition doesn’t affect the following condition
AND conversions.status = ('approved' or 'pending')
What I did mistake here?
Advertisement
Answer
You can use the IN operator in the WHERE clause like below;
SELECT clicks.offer_id, clicks.offer_name, clicks.country, clicks.device_type, clicks.os_name, conversions.name , clicks.ip_address as Session, conversions.conversion_ip as Conversion, conversions.currency as Currency , conversions.payout as Payout FROM clicks JOIN users ON clicks.affiliate_id = users.id LEFT JOIN conversions ON clicks.transaction_id = conversions.click_transaction_id WHERE clicks.affiliate_id = '2' AND conversions.status IN ('approved', 'pending') AND date(clicks.created_at) BETWEEN '2021-11-08' AND '2021-12-07';