Suchy Posted June 18, 2009 Share Posted June 18, 2009 I want to pull something like this off: word excel powerpoint 10 2 5 But I am getting results such as: word 10 2 5 Here is my query: SELECT COUNT(*) AS "word" FROM `signin` WHERE `event` LIKE "%word%" UNION SELECT COUNT(*) AS "excel" FROM `signin` WHERE `event` LIKE "%excel%" UNION SELECT COUNT(*) AS "powerpoint" FROM `signin` WHERE `event` LIKE "%powerpoint%" How can I fix up the query? Link to comment https://forums.phpfreaks.com/topic/162827-displaying-results-from-multiple-fields/ Share on other sites More sharing options...
Ken2k7 Posted June 18, 2009 Share Posted June 18, 2009 SELECT SUM(IF(event LIKE '%word%', 1, 0)) AS word, SUM(IF(event LIKE '%excel%', 1, 0)) AS excel, SUM(IF(event LIKE '%powerpoint%', 1, 0)) AS powerpoint FROM signin; Link to comment https://forums.phpfreaks.com/topic/162827-displaying-results-from-multiple-fields/#findComment-859261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.