In the scenario I have to get the data in the right order based on the precedence structure of the rows. Let the table data be:
Table (Desc - A part of B)
col1 col2 col3
a 1 11
a 1 12
a 1 13
b 2 21
b 2 22
b 2 23
Table (Desc - Sequence)
col1 col2 col3
aa 11 12
bb 13 14
cc 12 13
pp 21 22
qq 23 24
rr 22 23
The result I am expecting:
col1 col2
a aa
a cc
a bb
b pp
b rr
b qq
I'm using MySQL.