sql server - Select multiple value using subquery -


i have 3 tables:

  1. articles

  2. articletags

  3. article_articletags_rel

articletags_rel table has 2 columns

  1. articleid_fk

  2. tagid_fk

as can see article_articletags_rel make relation between articles , articletags

all want select 1 row articles table , and related tags (multiple values) using sub-query.

how can achieve this?

you can try this:

select a.name, b.tagname    article_articletags_rel c   inner join articles on a.id = c.articleid_fk   left outer join articletags b on b.id = c.tagid_fk 

result:

name    tagname --------------- art   tag 1 art   tag 2 art   tag 3 art b   tag 1 art b   tag 3 art c   tag 1 art c   tag 3 

sql fiddle: http://sqlfiddle.com/#!6/8d30f/2


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -