Hi all,
I have 2 tables as follows:
tags:
id
version
name
tag_links:
id
version
tag_id (foreign key to tags.id)
I need to write an SQL statement that returns how many times each tag_id occurs in tag_links table.
For example:
tags:
id version name
-- ------- ------
1 1 sport
2 1 comedy
tag_links:
id version tag_id
-- ------- ------
1 1 1
2 1 1
3 1 1
4 1 2
5 1 2
The result I need is:
tag_id times_occurred
------ --------------
1 3
2 2
I have a little knowledge of SQL and I tried to write it but :(
Thank you.