Delete duplicate values from a table

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
 
C

Clifford Bass

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top