July 16, 201313 yr hello me again with yet another sql query issue ive using this case to swap 0's with 1's and visa versa if the type is not R im using this at the moment CASE `orig_val` WHEN `orig_val` = 1 THEN "0" WHEN `orig_val` = 0 THEN "1" WHEN `type` = "R" THEN `orig_val` END as `value` but the above code always returns 0 not sure why Edited July 16, 201313 yr by D4Y0
July 16, 201313 yr hello me again with yet another sql query issue ive using this case to swap 0's with 1's and visa versa if the type is not R im using this at the moment CASE `orig_val` WHEN `orig_val` = 1 THEN "0" WHEN `orig_val` = 0 THEN "1" WHEN `type` = "R" THEN `orig_val` END as `value` but the above code always returns 0 not sure why so your orig_val can hold 1,0 and type can hold 'R' So 1 becomes 0 and 0 becomes 1. But you are not comparing "type" just orig_val" in the case switch ? I think i that's right, I could be totally wrong, but that's the logic i have come to.
July 16, 201313 yr Author Yea pretty much I fixes it by doing the case on the type and then if type = T it would minus the value from 1, for some reason it didn't like having 0 in the case] Example: case `type` WHEN "T" THEN 1-val ELSE val ENDThat way 1-1 = 0 and 1-0 = 1 and it was much less code, dont know why i ever post on here as as soon as i post i usualy find the awnser 10 mins later Edited July 16, 201313 yr by D4Y0
Create an account or sign in to comment