Home  >  Article  >  Database  >  mysql enum类型字段_MySQL

mysql enum类型字段_MySQL

WBOY
WBOYOriginal
2016-06-01 13:07:181215browse

ENUM是一个字符串对象,其值来自表创建时在列规定中显式枚举的一列值

每个数值都对应一个索引值,并且是按照创建字段时候规定的顺序,例如enum('a','b','c'),对应索引值为(1,2,3),null和''为保留值,只有当插入的值不再该范围内,就用数值0取代,可以用该方法来筛选是否非正常插入的数据 where column=0

在查询的时候要注意,特别是数值enum('0','1','2')对应索引值(1,2,3),where column=1,并不能查询出来该字段为1的数据,出来的结果会是列值为0的数据

只能写成where column='1',才是正确列值等于1的数据

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn