0

i am working on some Mysql assignment and was asked to:

All the employees who are managers (leaders, type 'L') get a salary increase of 6%.

i tried to use this method:

UPDATE employee
SET salary = salary * '1,06'
WHERE emptype = 'L';

and i get an Error message Error Code: 1292. truncated incorrect DOUBLE value: '1,06'

When i try to DESCRIBE employee;

i can see the salary to be Type int(11)

Can someone tell what i have done wrong and how the correct codding is, and is it possible to add those 6% on the current value without changing the Type?

karthikr
  • 97,368
  • 26
  • 197
  • 188
PuchuKing33
  • 381
  • 3
  • 7
  • 19
  • 1
    `'1,06'` is a string, not an integer. monetary data shouldn't be stored in a floating point-type field either. You will end up with wonky results at some point. money values should be a decimal, or at least a fixed-point integer. – Marc B Oct 16 '13 at 21:41
  • 1
    mysql wants the decimal separator to be a . (dot) rather than , (comma). See http://stackoverflow.com/questions/8669212/change-decimal-separator-in-mysql – GregA100k Oct 16 '13 at 21:41

1 Answers1

3

It should be this...

UPDATE employee
SET salary = salary * 1.06
WHERE emptype = 'L';

... instead. Not only '1,06' is a string - it's a string that cannot be cast into a corresponding numeric value without losing some data ('truncating', in other words) in process, as comma isn't treated as a decimal part separator - a dot is.

And that's exactly what MySQL tells you in this error message. It's just that subtle difference between a number and its string representation you've probably missed.

raina77ow
  • 103,633
  • 15
  • 192
  • 229