如何在 MySQL 中使用 SET 從句插入多個數據?


我們首先建立一個表 -

mysql> create table DemoTable1544
   -> (
   -> Id int ,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (2.47 sec)

使用 insert 命令在表中插入一些記錄。我們已經使用 SET 從句插入了多個數據 -

mysql> insert into DemoTable1544 set Id=101,Name='John Doe';
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable1544 set Id=102,Name='Adam Smith';
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1544 set Id=103,Name='Chris Brown';
Query OK, 1 row affected (0.12 sec)

使用 select 語句從表中顯示所有記錄 -

mysql> select * from DemoTable1544;

這將產生以下輸出 -

+------+-------------+
| Id   | Name        |
+------+-------------+
|  101 | John Doe    |
|  102 | Adam Smith  |
|  103 | Chris Brown |
+------+-------------+
3 rows in set (0.00 sec)

更新於: 12-Dec-2019

116 次瀏覽

開啟你的 職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.