Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #== PHP STYLE:
- $value=NULL;
- IF(in_array($dep ,array('a','b','c'))){
- IF(in_array($bag,array('x','y','z'))){
- $value=1.0;
- }elseif($grade<4){
- $value=1.2;
- }ELSE{
- $value=1.0;
- }
- }elseif($dep=='d'){
- IF(in_array($bag,array('f','g'))){
- $value=0.8;
- }ELSE{
- $value=1.0;
- }
- }elseif($dep=='j'){
- IF($bag='w'){
- $value=1.0;
- }ELSE{
- $value=0.8;
- }
- }elseif($dep=='e'){
- $value=1.0;
- }elseif(in_array($dept,array('h','i'))){
- $value=0.8;
- }
- #==another PHP STYLE:
- $value=in_array($dep ,array('a','b','c'))?(in_array($bag,array('x','y','z'))?1.0:($grade<4?1.2:1.0)):($dep=='d'?(in_array($bag,array('f','g'))?0.8:1.0):($dep=='j'?($bag=='w'?1.0:0.8):($dep =='e'?1.0,(in_array($dept,array('h','i'))?0.8:NULL))));
- #== SQL STYLE:
- SELECT
- IF(`dept` IN('a','b','c'),
- IF(`bagian` IN ('x','y','z'),
- 1.0,
- IF(`grade`<4,
- 1.2,
- 1.0
- )
- ),
- IF(`dept`='d',
- IF(`bagian` IN('f','g'),
- 0.8,
- 1.0
- ),
- IF(`dept`='j',
- IF(`bagian`='w',
- 1.0,
- 0.8
- ),
- IF(`dept`='e',
- 1.0,
- IF(`dept` IN('h','i'),
- 0.8,
- NULL
- )
- )
- )
- ) AS myvalue
- FROM `table_name`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement