0
(select  abc.name as value,'id' as label 
union all 
select abc.line1 as value,'address' as label 
)
from
(select broin_kid as kid,broinlaw_name as name, brinla_line1 as line1 from broinlaw_det   where bro_prvuser = 4 )  abc

Please help me i need to execute same in mysql

Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52
Puneeth
  • 21
  • 1
  • give your sample table structure with some values – Madhur Bhaiya Aug 17 '18 at 13:21
  • Unless you are using a MySQL-version that supports ctes, you need to repeat the from part for each part of the union (so `select ... as label from (your current from-query) union all select ... as label from ( your current from-query )` – Solarflare Aug 17 '18 at 13:40
  • thanx @Solarflare,presently am using as u metioned only but any other way is thr to get same result ... – Puneeth Aug 17 '18 at 15:18
  • Yes, you can also use a join. See e.g. [this](https://stackoverflow.com/a/15192571/6248528) answer which presents you 2 options: the first using the table repeatedly (your current solution), the other one using a join (which you may find prettier). You can google for "unpivot MySQL", maybe you find other ways to do it, but those are the two main solutions (unless you upgrade to MySQL 8, so you can use CTEs). – Solarflare Aug 17 '18 at 15:48
  • thanx @Solarflare.... – Puneeth Aug 17 '18 at 16:57

0 Answers0