ISSUE: Mysql converting Enum to Int

前端 未结 6 700
醉话见心
醉话见心 2021-01-11 18:25

I have a very simple rating system in my database where each rating is stored as an enum(\'1\',\'-1\'). To calculate the total I tried using this statement:



        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 19:09

    Yes, I'd suggest to change the type of the column. The issue becomes clear when you read the doc about enum type (which strongly recommends not to use numbers as enumeration values!) - the index of the enum item is returned, not the enum value itself.

提交回复
热议问题