i have following tables:
post (id, title, author_id) etc tags post_tags author the following sql query seems first thread, along all tags.
select post. * , author.username, group_concat( distinct tag.name order tag.name desc separator ',' ) tags author, post join post_tags on post.id = post_tags.thread_id join tag on post_tags.tag_id = tag.id author.id = post.author_id what doing wrong here?
you use group_concat() group by clause.
without group by, means group rows 1 , show group concatenation of tags.
the first thread data see byproduct of myqsl ill-behaviour allows show fields in select not dependent on grouping fields (none in case).
try query adding group post.id @ end.
select post. * , author.username , group_concat( distinct tag.name order tag.name desc separator ',' ) tags author join post on author.id = post.author_id join post_tags on post.id = post_tags.thread_id join tag on post_tags.tag_id = tag.id group post.id
Comments
Post a Comment