mysql - SQL Switch even/odd values of the selection -


currently have selection 2 tables:

(select e.id, e.num, '1' tbl events e )  union  (select p.id, p.num, '2' tbl places p )  order 2 desc 

it returns values ordered num this:

id  |  num  |  tbl  3  |    9  |    2  1  |    8  |    2  4  |    7  |    1  1  |    4  |    1  7  |    1  |    2 

but goal mix tables in selection not losing order within specific table. this:

id  |  num  |  tbl  3  |    9  |    2  4  |    7  |    1  1  |    8  |    2  1  |    4  |    1  7  |    1  |    2 

thanks in advance! appreciate help!

if want interleave tables, need additional information. if enumerate each row, can use sorting. this:

(select e.id, e.num, '1' tbl, (@rn1 := @rn1 + 1) rn  events e cross join       (select @rn1 := 0) vars  order e.num desc ) union (select p.id, p.num, '2' tbl, (@rn2 := @rn2 + 1) rn  places p cross join       (select @rn2 := 0) vars  order p.num desc ) order rn, tbl desc; 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -