Join Query for Count in mysql statement -


sql fiddle

i have 3 db tables , i'd select 10 used tags song_tag table, can sql query below

select `tag_id`,  count(`tag_id`) `value_occurrence`  `song_tag` group `tag_id` order `value_occurrence` desc  limit 10; 

how tag name value tags table in same query? possible? have set fiddle dummy data , 3 tables needed.(link @ top of post).

this used in wordpress wpdb query. don't think there else add configuration setup, languages etc.

you need join tags table result. like:

select s.tag_id, count(s.tag_id) value_occurrence, t.name song_tag s left join tags t     on s.tag_id = t.id group s.tag_id order value_occurrence desc limit 10; 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -