让我们首先创建一个表-
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, PlayerName varchar(100), PlayerScore int );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable(PlayerName,PlayerScore) values('Chris',780); mysql> insert into DemoTable(PlayerName,PlayerScore) values('Sam',1100); mysql> insert into DemoTable(PlayerName,PlayerScore) values('Mike',900); mysql> insert into DemoTable(PlayerName,PlayerScore) values('Bob',890); mysql> insert into DemoTable(PlayerName,PlayerScore) values('Carol',1000);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+----+------------+-------------+ | Id | PlayerName | PlayerScore | +----+------------+-------------+ | 1 | Chris | 780 | | 2 | Sam | 1100 | | 3 | Mike | 900 | | 4 | Bob | 890 | | 5 | Carol | 1000 | +----+------------+-------------+ 5 rows in set (0.00 sec)
以下是删除值大于MySQL中特定值的字段的查询-
mysql> delete from DemoTable where PlayerScore > 900;
让我们再次检查表记录。
mysql> select *from DemoTable;
这将产生以下输出-
+----+------------+-------------+ | Id | PlayerName | PlayerScore | +----+------------+-------------+ | 1 | Chris | 780 | | 3 | Mike | 900 | | 4 | Bob | 890 | +----+------------+-------------+ 3 rows in set (0.00 sec)