sql - Joining Tables and Displaying Result as Text, in one column -


i need join 2 columns 2 tables , display them in specific order

table1 , columnnm
table2 , columndesc

the primary key columnid

i have multiple rows of columndesc each columnnm. have display in following format:

 columnid columnnm ------------------- columndesc columndesc columndesc columndesc  columnid columnnm ------------------- columndesc columndesc  columnid columnnm ------------------- columndesc columndesc columndesc  

i have display results text, instead of grid. suggestions on how this? have create stored procedure. appreciated. below far got:

declare @name nvarchar(max), @lesson nvarchar(max), @lb nvarchar(max) set @lb = '----------------------------------------------------'  select  @name = module.name module join lesson on module.modulesequence = lesson.modulesequence module.modulesequence = 1 print '1 ' +  @name print @lb  select lesson.description  module join lesson on module.modulesequence = lesson.modulesequence module.modulesequence = 1 

but think i'm way off.

..........................................okay, edit, after john tabernik suggestion got this......................................

(p.s. sorry adding comment answer, learning how use stackoverflow)

select m.name, l.description module m     join lesson l         on m.modulesequence = l.modulesequence order m.name, l.description 

i end getting m.name repeated 4 times there 4 different l.description first m.name, , different amounts other m.name's.

example:

m.name | l.description -----------------------------      |    1      |    2      |    3 b      |    1 b      |    2 c      |    1 c      |    2 c      |    3 

but need output this:

a   | ----- 1   | 2   | 3   |  b   | ----- 1   | 2   |  c   | ----- 1   | 2   | 

how important sections being set apart header , "-------" line have it? simple sql not this, if results can , ordered, easy.

you want this:

select column1, column2 table1 t1     join table2 t2           on t1.id = t2.foreignkey order column1, column2 

you can make use of whatever pulls data out format it, general approach data, sorted way want. luck!


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -