If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > convert MS Access DELETE statement to MySQL (was "Please help me, URGENT")

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-05, 01:44
SKJoy SKJoy is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Unhappy convert MS Access DELETE statement to MySQL (was "Please help me, URGENT")

Trouble
=======================
The following SQL works in MS Access but denies in MySQL;

"DELETE FROM tblcdr WHERE tblcdr.CID IN (SELECT CID FROM tblcdr AS C WHERE C.CID = tblcdr.CID AND C.cdrID > tblcdr.cdrID)"
=======================

"tblcdr" specification
=======================
CDRID -> int, auto_increament
CDID -> int
=======================

Purpose
=======================
I am capturing data from a hardware device that serves the data in CSV format. I then export the data right into the database. Upto this part, thigns are alright.

Now, whenever I lose connectivity with the device, it starts from the start of the data stream when I reconnect with it. It causes the duplication of thousands of data thousand times.

So I needed an SQL DELETE query that will delete the rows that are the duplicates leaving the parent (orginal) row intact.

Here the CDID column is the unique identifier supplied by the device, so for the rows with same CDID, we can call them duplicates. Please don't be confused with CDRID & CDID. CDRID is the actual IDENTITY column in the table & values for CDID is supplied by the device.
=======================

Thanks in advance...
__________________
Shahriar Kabir
Reply With Quote
  #2 (permalink)  
Old 02-15-05, 11:01
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
see this other thread for an example of a delete strategy you could use
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On