- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Insert all the values in a table with a single MySQL query separating records by comma
Let us first create a table −
mysql> create table if not exists DemoTable1343 -> ( -> `_ClientId` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(40), -> ClientProjectDeadline date -> )ENGINE=MyISAM,AUTO_INCREMENT=1000; Query OK, 0 rows affected (0.21 sec)
Insert some records in the table using insert command with a single query −
mysql> insert into DemoTable1343(ClientName,ClientProjectDeadline) values('Chris','2019-09-24'),('Bob','2015-12-09'), -> ('Mike','2017-01-20'),('Carol','2018-03-31'); Query OK, 4 rows affected (0.10 sec) Records: 4 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select * from DemoTable1343;
This will produce the following output −
+-----------+------------+-----------------------+ | _ClientId | ClientName | ClientProjectDeadline | +-----------+------------+-----------------------+ | 1000 | Chris | 2019-09-24 | | 1001 | Bob | 2015-12-09 | | 1002 | Mike | 2017-01-20 | | 1003 | Carol | 2018-03-31 | +-----------+------------+-----------------------+ 4 rows in set (0.00 sec)
Advertisements