I have a query where I have to look in 3 columns from a table where I have 2 columns searched on message column and last column should be on like . how can I use both statements at a time.
SELECT date(datetime) as dateonly ,
sum(CASE message when 'Accepted Images' then 1 else 0 end) as AcceptedIMG,
sum(CASE message when 'Rejected Images' then 1 else 0 end) as RejectedIMG,
sum(CASE when message like '%Changed to %' then 1 else 0 end) as ChangeIMG
FROM customer_1.audit_trail
WHERE message like ('%Changed to %') and message in ('Accepted Images','Rejected Images')
GROUP BY (dateonly)
ORDER BY (dateonly) asc ;
You can use OR (and group your condition)
SELECT date(datetime) as dateonly ,
sum(CASE message when 'Accepted Images' then 1 else 0 end) as AcceptedIMG,
sum(CASE message when 'Rejected Images' then 1 else 0 end) as RejectedIMG,
sum(CASE when message like '%Changed to %' then 1 else 0 end) as ChangeIMG
FROM customer_1.audit_trail
WHERE (message like ('%Changed to %') OR message in ('Accepted Images','Rejected Images'))
GROUP BY (dateonly)
ORDER BY (dateonly) asc ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.