在 MySQL 中使用下表:
CREATE TABLE bob(foo ENUM('a','b','c'));
INSERT INTO bob (foo) VALUES ('a'),('b'),('c'),('a'),('a');
SELECT * FROM bob WHERE foo >= 2;
+------+
| foo |
+------+
| b |
| c |
+------+
Run Code Online (Sandbox Code Playgroud)
使用 PostGres 中的下表:
CREATE TYPE stuff AS ENUM ('a', 'b', 'c');
INSERT INTO bob (foo) VALUES ('a'), ('b'), ('b'), ('c'), ('c');
SELECT * FROM bob WHERE foo > 2;
(HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.) …Run Code Online (Sandbox Code Playgroud)