database - Join multiple column with single row using mySql -
i have query results in single row like: (table_1) | col_1 | col_2 | col_3 | row->1 | | b | c | another query results in 2 rows like: (table_2)
| col_1 | col_2 | row->1 | | x | row->2 | | y | common value both table col_1(a). need like:
| col_1 | col_2 | col_3 | col_4 | col_5 | | | b | c | x | y | please provide simplest way achive this.
you can try it-
select a.col_1,a.col_2,a.col_3, (select b.col_2 table2 b b.col_1=a.col_1 limit 1) col_4, (select b.col_2 table2 b b.col_1=a.col_1 limit 1,1) col_5 table1;
Comments
Post a Comment