1

This

DELETE FROM `z_ratings` 
WHERE `score` = '5.4' 
  AND `media_id` = '242' 
  AND `user_id` = '1'

will not delete the following row:

enter image description here

Can anybody explain why?

(I'm assuming the issue is with the float since both other columns are integers)

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
Callombert
  • 1,099
  • 14
  • 38

1 Answers1

1

The problem is the floating point column. You can review the issues with this representation and comparisons. One place to start is the documentation.

Great, we know it doesn't work. More importantly, what can you do?

Probably the most accurate solution is to switch to decimal, say decimal(5, 1) for the column. Then, this shouldn't be a problem.

Alternatively, use abs() and difference for a fuzzy comparison:

abs(score - 3.4) < 0.0001
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786