Reputation: 24
SELECT logic_id
FROM business_logic_details
WHERE if(form_completion != 0.00,form_completion,0) = '90'
AND if(query_type IS NOT NULL
OR query_type !='',query_type,0) LIKE '%domestic%'
AND if(client_type IS NOT NULL
OR client_type !='',client_type,0) LIKE '%existing%'
AND if(tour_package IS NOT NULL
OR tour_package !='',tour_package,0) LIKE '%S%'
AND if(tour_type IS NOT NULL
OR tour_type !='',tour_type,0) LIKE '%2%'
AND if(currency IS NOT NULL
OR currency !='',currency,0) = 'INR'
AND if(country IS NOT NULL
OR country !='',country,0) = '105'
AND if(adults IS NOT NULL
OR adults !='',adults,0) = '1'
AND if(duration_of_stay IS NOT NULL
OR duration_of_stay !='',duration_of_stay,0) = '5'
ORDER BY logic_id ASC
Upvotes: 0
Views: 75
Reputation: 17701
Use COALESCE function for that:
SELECT logic_id
FROM business_logic_details
WHERE COALESCE(form_completion, 90) = 90
AND COALESCE(query_type, 'domestic') LIKE '%domestic%'
...
I also strongly suggest to compare integers as integers, and not as strings:
Good: 0 = 90
Bad: 0 = '90'
Upvotes: 1