sql - Adding two tables with no column in common in MySQL -
i have 2 tables database. want append these 2 tables. not able find solution it
table 1 -
names first_name last_name navjot singh ram gopal naveen kumar
table 2 -
address address pin delhi 90007 lucknow 90003 mumbai 60008
how data these 2 tables in following format:
first_name last_name address pin navjot singh delhi 90007 ram gopal lucknow 90003 naveen kumar mumbai 60008
these sample tables. want thing on 50,000 rows. number of rows same in both tables. have tried cross join. have tried following sql well:
select * names,address;
it increases total number of rows. tried union, did not work.
it cbind.data.frame in r. how in mysql? appreciated.
the problem have no column join. assuming have column specify ordering, can do:
select t1.*, t2.* (select t.*, (@rn := @rn + 1) seqnum table1 t cross join (select @rn := 0) params order t.id ) t1 join (select t.*, (@rn2 := @rn2 + 1) seqnum table2 t cross join (select @rn2 := 0) params order t2.id ) t2 on t1.seqnum = t2.seqnum;
this generates sequential key each row in each of tables. key used joins.
Comments
Post a Comment