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: 2019-10-04T07:19:24+05:30

757 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements