I am trying to count the entries in rows in a MySQL table:
Example data:
+------------------------------------------------+
| facebook_id | linkedin_id | twitter_id | vk_id |
+------------------------------------------------+
1234143134 0 13413993 13499
0 0 0 0
12313431334 0 13413243 0
12341431340 13419194319 13419943 13413
0 0 0 0
+------------------------------------------------+
The aim is to display how many of each _id has an entry. In the above example, facebook has 3, LinkedIn has 1 and twitter has 3 and vk has 2.
Here is my attempt at counting them:
COUNT(`facebook_id`) AS `facebook`,
COUNT(`linkedin_id`) AS `linkedin`,
COUNT(`twitter_id`) AS `twitter`,
COUNT(`vk_id`) AS `vkontakte`
FROM `user`
How can this be fixed? Thanks :)