Deleting First Record Only

Joined
Jan 15, 2009
Messages
21
Programming Experience
5-10
I have a vb.net app that manages orders for a small retail store. If they have placed two of the same item in the same order and only need 1, there is a button to delete the item from the database.

The problem comes in my SQL statement which is "DELETE FROM OrderSpecs WHERE Style = '" & style & "' AND Color = '" & color & "' AND Order = '" & order & "' "

This removes both entries from the database since they have the same values. I was wondering if there is a way to delete only the first entry that fits this statement. Thanks
 
Thanks cjard. That does work, but it isn't worth the risk of losing valuable information for the store. By the way, it is INSERT instead of SELECT. I am just going to go back and add primary keys.
 
Thanks cjard. That does work, but it isn't worth the risk of losing valuable information for the store.
This statement doesnt quite make sense, for the reasons outlined above. You have no way of knowing which record you want to keep, so it's not like one way will lose info and another way won't!


By the way, it is INSERT instead of SELECT. I am just going to go back and add primary keys.

SELECT INTO (in microsoft platforms) creates a table from a query
INSERT INTO inserts into an existing table
 
Back
Top