修复错误 1093 (HY000):删除 MySQL 列中的最小值时,无法在 FROM 子句中指定用于在更新中的目标表?
我们首先创建一个表 -
mysql> create table DemoTable1597 -> ( -> Marks int -> ); Query OK, 0 rows affected (0.69 sec)
使用 insert 命令在表中插入一些记录 -
mysql> insert into DemoTable1597 values(45); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1597 values(59); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1597 values(43); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1597 values(85); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1597 values(89); Query OK, 1 row affected (0.12 sec)
使用 select 语句显示表中的所有记录 -
mysql> select * from DemoTable1597;
这将产生以下输出 -
+-------+ | Marks | +-------+ | 45 | | 59 | | 43 | | 85 | | 89 | +-------+ 5 rows in set (0.00 sec)
以下是消除错误 1093 (HY000) 的查询。我们在此处删除了最小值 -
mysql> delete from DemoTable1597 -> where Marks=( -> select lowestMarks from ( select min(Marks) as lowestMarks from DemoTable1597 ) as deleteRecord -> ) limit 1; Query OK, 1 row affected (0.11 sec)
让我们再次检查表记录 -
mysql> select * from DemoTable1597;
这将产生以下输出 -
+-------+ | Marks | +-------+ | 45 | | 59 | | 85 | | 89 | +-------+ 4 rows in set (0.00 sec)
广告