sql - mysql "paste" two results together (side by side) -


i want paste command in unix, takes 2 files , prints first line, of first file, separator, first line second file, newline, second line first file separator second line second file, etc.

so want in sql, take columns 2 tables, output result, columns of first rows (as 1 row) first , second table, second rows both tables etc. without cross join stuff first row first table second row second table etc. possible? hard search on net...

edit:

table 1:          table 2: column bla        column cla                 80 z                 7 f                 15 k  expected result: column bla, column cla a, 80 z, 7 f, 15 k, null 

very simple :), except not @ all...

edit2: please no @variables

create table if not exists first_40482804 (     bla varchar(50) ) ;  create table if not exists second_40482804 (     cla int ) ;  truncate table first_40482804 ; truncate table second_40482804 ;  insert first_40482804 ( bla ) values ('a') ; insert first_40482804 ( bla ) values ('z') ; insert first_40482804 ( bla ) values ('f') ;  insert second_40482804 ( cla ) values ( 80 ) ; insert second_40482804 ( cla ) values ( 7 ) ; insert second_40482804 ( cla ) values ( 15 ) ;  set @blarow = 0 ; set @clarow = 0 ;  select concat( `first`.bla,',',`second`.cla) paste (        select @blarow:=@blarow+1 `row` , bla first_40482804 ) `first` left join  (     select @clarow:=@clarow+1 `row` , cla second_40482804 ) `second` on `first`.`row` = `second`.`row` 

-- results

paste a,80 z,7 f,15 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -