让我们首先创建一个表-
create table DemoTable -> ( -> EmployeeStatus ENUM('FULLTIME','Intern') default NULL -> );
使用插入命令在表中插入一些记录-
insert into DemoTable values('FULLTIME'); insert into DemoTable values('Intern'); insert into DemoTable values('Intern'); insert into DemoTable values();
使用select语句显示表中的所有记录-
select * from DemoTable;
这将产生以下输出-
+----------------+ | EmployeeStatus | +----------------+ | FULLTIME | | Intern | | Intern | | NULL | +----------------+ 4 rows in set (0.00 sec)
这是使用MySQL中的ENUM字段选择行的查询-
select * from DemoTable -> where EmployeeStatus is null or EmployeeStatus <> 'Intern';
+----------------+ | EmployeeStatus | +----------------+ | FULLTIME | | NULL | +----------------+ 2 rows in set (0.00 sec)