我们如何借助MySQL自计算输出将值插入表中?
我们可以借助MySQL返回的自计算输出将值插入表中。在这种情况下,我们不需要使用虚拟的“双重”表。语法可以如下-
INSERT INTO table_name(column1,column2,column3,…) Select value1,value2,value3,…;
示例
在下面的示例中,我们使用MySQL自我计算的输出将值插入了“测试”表。
mysql> Create table testing(id int, item_name varchar(10)); mysql> Insert into testing (id,item_name)Select 1,'Book'; Records: 1 Duplicates: 0 Warnings: 0 mysql> Insert into testing (id,item_name)Select 2,'Pen'; Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from testing; +------+-----------+ | id | item_name | +------+-----------+ | 1 | Book | | 2 | Pen | +------+-----------+ 2 rows in set (0.00 sec)
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短