John Davidson

php - how to remove duplicate records?

0 comments
Message:


I want to import excel sheet data to sql database.In database there are already have records, i want to import another records from excel and want remove duplicate records.
how can I do it


1st Table




2nd Table




I want to import 2 tables to 1 table and remove duplicate records



My Answer:
To remove duplicate records when importing data from Excel to a SQL database, you can follow these steps:

1. Import the data from the Excel sheets into temporary tables in the database. You can use tools like MySQL Workbench or phpMyAdmin to import the data.

2. Use SQL queries to insert the data from the temporary tables into the main table, while also removing any duplicate records. You can use the following query to insert data from the first table into the main table and remove duplicates:

sql
INSERT INTO main_table
SELECT * FROM first_table
ON DUPLICATE KEY UPDATE id=id;


3. Repeat the same process for the second table:

sql
INSERT INTO main_table
SELECT * FROM second_table
ON DUPLICATE KEY UPDATE id=id;


4. Finally, you can drop the temporary tables that were used for importing the data.

By following these steps, you can import data from multiple tables into one table in the database and remove any duplicate records during the process.

Rate this post

5 of 5 based on 3682 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us