Delete duplicate values from a table

  • Thread starter Thread starter JUNEBUG
  • Start date Start date
J

JUNEBUG

duplicates based on two fields
see table below..
INB/OUT, ORDER#, LITEM#
IN, ORDER1, item1
IN, ORDER1, item2
OB, ORDER1, item1
IN, ORDER2, item1
IN, ORDER2, item2
OB, ORDER2, item1
OB, ORDER2, item2
OB, ORDER3, item1

FIRST, duplicate ORDERS that match IN and OB delete IN only
SECOND delete all ORDERS & LITEM# that match IN and OB then delete IN only.

Thanks in advace
 
Hi,

First, make a backup of your database, or the table so that you can
restore if this does not work correctly.

Step 1:

delete from yourtable as A
where [INB/OUT] = "IN" and exists
(select * from yourtable as B
where B.[INB/OUT] = "OB" and B.[ORDER#] = A.[ORDER#] and B.[LITEM#] =
A.[LITEM#]);

Step 2: ...

But now as I look more at your question, I become confused. How about
you finish up your example and show what you expect after each step and
explain exactly why the specific records have been deleted?

Clifford Bass
 
Back
Top