Insert multiple values in a temporary table with a single MySQL query?


Let us first create a table −

mysql> create temporary table DemoTable
(
   SerialNumber int
);
Query OK, 0 rows affected (0.00 sec)

Insert some records in the table using insert command. Here, we are inserting multiple values in a temporary table −

mysql> insert into DemoTable values(1),(2),(3),(4),(5),(6),(7),(8);
Query OK, 8 rows affected (0.00 sec)
Records: 8 Duplicates: 0 Warnings: 0

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+--------------+
| SerialNumber |
+--------------+
|            1 |
|            2 |
|            3 |
|            4 |
|            5 |
|            6 |
|            7 |
|            8 |
+--------------+
8 rows in set (0.00 sec)

Updated on: 04-Oct-2019

638 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements