This is useful when you want to insert all columns from the first table to the second table, and no conditional statements are required. The TABLE statement does the same work as the SELECT * FROM statement above. INSERT INTO table1 TABLE table2 Code language: SQL (Structured Query Language) ( sql ) We will see the syntax of the INSERT INTO SELECT statement first and then focus on the conditions of using it, followed by some examples. However, your query has restrictions before using the INSERT INTO SELECT statement. Moreover, you can insert the data from more than one table into the new table using this statement. When you want to copy all the data or data of only particular columns from one table to another, you can use the INSERT INTO SELECT statement. The INSERT INTO SELECT statement is, you can say, a combination of these above two statements. In MySQL, you can use a SELECT statement to get the data from the table and the INSERT statement to insert the data into the table. We will also be looking at its syntax, examples, and points that you should avoid getting successful results from the given statement.Īlso read: MySQL Select Statement – Fetching Data from MySQL Databases What is INSERT INTO SELECT Statement In official MySQL documentation, it is described as INSERT … SELECT however, people prefer calling it INSERT INTO SELECT.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |