4
I need to make an SQL query to count indications, I have the following querys:
SELECT 'FACEBOOK', COUNT(id) FROM `clientes` where indicacao like '%face%'
SELECT 'Instagram', COUNT(id) FROM `clientes` where indicacao like '%insta%'
SELECT 'google', COUNT(id) FROM `clientes` where indicacao like '%google%'
SELECT 'panfleto', COUNT(id) FROM `clientes` where indicacao like '%panf%'
SELECT 'indicacao', COUNT(id) FROM `clientes` where indicacao like '%ind%'
SELECT 'radio', COUNT(id) FROM `clientes` where indicacao like '%radio%'
SELECT 'outros', COUNT(id) as total FROM `clientes` where indicacao not like '%radio%' and indicacao not like '%face%' and indicacao not LIKE '%insta%' and indicacao not like '%google%' and indicacao not like '%panf%' and indicacao not like '%ind%' and indicacao not like '%radio%'
My question is: I can do that same research without having to do all these querys?
I put now with using
LIKE
, but you could remove spaces too if you were sure not to have other unwanted characters.– Caique Romero
Beauty, excellent response. + 1 (Y)
– Laércio Lopes
Good! valeuu!!!!
– Cesar Vinicius