Note that there are some explanatory texts on larger screens.

plurals
  1. POSimplify Multiple Join SQL Column
    primarykey
    data
    text
    <p>i have select statment query with join statment, which I use to get value from joining the table</p> <p>here's my Select query:</p> <pre><code>select case when p1.Value2 is not null then p1.Value3 end as fix1, case when p1.Value2 is not null then p2.Value3 end as fix2, case when p1.Value2 is not null then p3.Value3 end as fix3, case when p1.Value2 is not null then p4.Value3 end as fix4, case when p1.Value2 is not null then p5.Value3 end as fix5, case when p1.Value2 is not null then p6.Value3 end as fix6 from tc t left join (select * from Parameter where paramtype='fix') as p1 on p1.Value2 = t.FIX left join (select * from Parameter where paramtype='fix') as p2 on p2.Value2 = t.FIX1 left join (select * from Parameter where paramtype='fix') as p3 on p3.Value2 = t.FIX2 left join (select * from Parameter where paramtype='fix') as p4 on p4.Value2 = t.FIX3 left join (select * from Parameter where paramtype='fix') as p5 on p5.Value2 = t.FIX4 left join (select * from Parameter where paramtype='fix') as p6 on p6.Value2 = t.FIX5 where CUST_ACCT ='10053996' </code></pre> <p>I thought its to complicated , so I change my code like this :</p> <pre><code>select fix +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = fix) as fix, FIX1 +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = FIX1) as FIX1, FIX2 +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = FIX2) as FIX2, FIX3 +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = FIX3) as FIX3, FIX4 +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = FIX4) as FIX4, FIX5 +' '+(select Value3 from Parameter where ParamType = 'fix' and Value2 = FIX5) as FIX5 from tc where CUST_ACCT ='10053996' </code></pre> <p>is it possible to simplify my code ? or if I wanna do something like this I should Create select statment like that?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload