Imagine that there is clicks table which contains users clicks. Now I want to select the total clicks per social network:
UPD: refererHost column contains any referer host, not only social network host.
SELECT
c.refererHost as referer,
COUNT(c.id) as clicks
FROM clicks c
WHERE c.referrerHost REGEXP 'facebook|google|linkedin'
GROUP BY referer
ORDER BY clicks desc
But the problem is that referer field will contain domain name like www.facebook.com, and I need to select matched regexp value (e.g. 'facebook'). Is it possible to do it with MySQL?