mysql - Matched Rows From Two Table and Display Them As New Row -


suppose, i've data in table table 1 follows:

quesid quesname             1 question 1      2 question 2      3 question 3      4 question 4 

in table 2, follows:

id quesid mainquesid  1      4          1  2      2          2  

i want have following output:

quesid quesname             1 question 1      1 question 4      2 question 2      2 question 2      3 question 3      4 question 4 

is possible sql? tried following return questions if not match id (order mainquesid):

select m.quesid      , m.quesname   table_1 m   group      m.quesid      ,m.quesname  union  select k.quesid      , m.quesname   table_2 k 

i assume, result posted, entries table_2 listed mainquesid.

select *      ((select t1.quesid, t1.quesname table_1 t1)     union (select t2.mainquesid quesid, t1.title quesname         table_2 t2 join table_1 t1 on t1.quesid = t2.quesid))     union_table     order union_table.quesid 

the table_2 joined table_1 question title each qstnid.

then both tables brought format (quesid, quesname), unioned them, ordered them quesid.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -