让我们首先创建一个表-mysql> create table DemoTable1884
(
Marks int
);
使用插入命令在表中插入一些记录-mysql> insert into DemoTable1884 values(55);
mysql> insert into DemoTable1884 values(97);
mysql> insert into DemoTable1884 values(79);
mysql> insert into DemoTable1884 values(87);
使用插入命令在表中显示一些记录-mysql> select * from DemoTable1884;
这将产生以下输出-+-------+
| Marks |
+-------+
| 55 |
| 97 |
| 79 |
| 87 |
+-------+
4 rows in set (0.00 sec)
这是field()使用OR实施订单的查询:mysql> select * from DemoTable1884 where Marks = 98 or Marks = 87 order by field(Marks,98,87) limit 1;
这将产生以下输出-+-------+
| Marks |
+-------+
| 87 |
+-------+
1 row in set (0.00 sec)