Advertisement
cdsatrian

pilihan

Apr 22nd, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.21 KB | None | 0 0
  1. #== PHP STYLE:
  2. $value=NULL;
  3. IF(in_array($dep ,array('a','b','c'))){
  4.   IF(in_array($bag,array('x','y','z'))){
  5.     $value=1.0;
  6.   }elseif($grade<4){
  7.     $value=1.2;
  8.   }ELSE{
  9.     $value=1.0;
  10.   }
  11. }elseif($dep=='d'){
  12.   IF(in_array($bag,array('f','g'))){
  13.     $value=0.8;
  14.   }ELSE{
  15.     $value=1.0;
  16.   }
  17. }elseif($dep=='j'){
  18.   IF($bag='w'){
  19.     $value=1.0;
  20.   }ELSE{
  21.     $value=0.8;
  22.   }
  23. }elseif($dep=='e'){
  24.   $value=1.0;
  25. }elseif(in_array($dept,array('h','i'))){
  26.   $value=0.8;
  27. }
  28.  
  29. #==another PHP STYLE:
  30.  
  31. $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))));
  32.  
  33. #== SQL STYLE:
  34. SELECT
  35. IF(`dept` IN('a','b','c'),
  36.   IF(`bagian` IN ('x','y','z'),
  37.     1.0,
  38.     IF(`grade`<4,
  39.       1.2,
  40.       1.0
  41.     )
  42.   ),
  43.   IF(`dept`='d',
  44.     IF(`bagian` IN('f','g'),
  45.       0.8,
  46.       1.0
  47.     ),
  48.     IF(`dept`='j',
  49.       IF(`bagian`='w',
  50.         1.0,
  51.         0.8
  52.       ),
  53.       IF(`dept`='e',
  54.         1.0,
  55.         IF(`dept` IN('h','i'),
  56.           0.8,
  57.           NULL
  58.         )
  59.       )
  60.     )
  61.   ) AS myvalue
  62. FROM `table_name`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement