samedi 30 janvier 2016

Apply condition to MySQL as a result of IF statement

I have a query:

SELECT campaign_id, campaign_balance, campaign_email
FROM campaigns
WHERE campaign_unique = 0
LIMIT 1

But I only want to apply the WHERE campaign_unique = 0 condition to the above query when the following returns a one:

SELECT COUNT(earning_id) FROM earnings WHERE earning_ip = '77.166.56.152' LIMIT 1

Is there some way I can apply an IF statement to decide whether or not to apply a WHERE condition?

Aucun commentaire:

Enregistrer un commentaire