We can copy the whole table or its specific columns we want to copy.
Create table and copy another table data
CREATE TABLE users AS SELECT * FROM admission;
Or
INSERT INTO admission(name,village,district,state,country) SELECT * FROM users;
But column count in both tables should match if you use all column selector ( * ). In the above example, the admission table contains five columns & the users table also contains five columns. The column name may be different in both tables.
Copy specific column data
INSERT INTO admission(name) SELECT name FROM users;
- Introduction to SQL
- SQL query to create a database
- SQL query to create a table
- SQL query to store data in the table
- Delete database query
- SQL query to delete table
- SQL update query
- Empty SQL database table
- SQL query to delete column
- Add column query
- Display (pull) data from the table
- Data sorting in SQL (Arrange data in ascending or descending order)
- SQL MIN() and MAX() functions
- SQL CASE (apply conditions in sql)
Publish A Comment