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? Quote 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; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.