0

in the image, these are the records in my tables from two different tables which are linked together through the "CUSTABN". As the records from these tables are duplicated, so I want to delete all the duplicate records.

Records from multiple tables (Customer & Invoice)

enter image description here

Can anyone help?

4
  • want to delete duplicates or want to select distinct values from 2 tables ? Commented Apr 21, 2016 at 14:39
  • I want to delete the duplicate records from two tables that is linked together. the tables is in the link on top of this page (Records from multiple tables (Customer & Invoice)) Commented Apr 21, 2016 at 14:40
  • 1
    are you sure the data are duplicated and are not the result of a join ?... in this case you need a select distinct and not a delete .. Commented Apr 21, 2016 at 14:43
  • that records are combination of both tables. but is it possible to delete? Commented Apr 21, 2016 at 14:46

1 Answer 1

1

If your tables are related with foreign key field "CUSTABN", I think this is what you want :

DELETE T1, T2 FROM T1 JOIN T2 ON T1.CUSTABN = T2.CUSTABN WHERE ...
Sign up to request clarification or add additional context in comments.

2 Comments

would you please make a clear query because am stuck on how to delete records from two related tables
You can use this query without any condition ( without WHERE clause ) and it will delete all records returned from join ( duplicate records ), but first test it on two test table to ensure that I correctly discovered what you want !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.