Reputation: 4553
I have the SQL query like this
select * from tablename where Fieldname not in (10005347797,1006009285)
My aim is to delete remaining records not in that id.So before that I want to see all the records in that table those are going to be deleted.
If you know how to delete that records you can give me delete command also.
Upvotes: 0
Views: 1688
Reputation: 174
FoxPro commands to get the result for you:
BROWSE LAST FOR NOT INLIST(FIELDNAME, 10005347797, 1006009285) && view/edit the records
DELETE FOR NOT INLIST(FIELDNAME,10005347797, 1006009285) && mark the records for deletion
PACK && permanently delete the marked records
Note: Based on my experience with FoxPro, these commands should work with any version of FoxPro. However it is not tested.
Upvotes: 1
Reputation: 993
The following code demonstrates how to use a SQL command to delete records.
CREATE CURSOR Table1 (pk I) INSERT INTO Table1 (pk) VALUES(1) INSERT INTO Table1 (pk) VALUES(2) INSERT INTO Table1 (pk) VALUES(3) INSERT INTO Table1 (pk) VALUES(4) INSERT INTO Table1 (pk) VALUES(5) SELECT Table1.* FROM Table1 WHERE Table1.pk NOT IN (2, 4) DELETE FROM Table1 WHERE Table1.pk NOT IN (2, 4)
Upvotes: 1
Reputation: 70
A question:
type of 10005347797 and 1006009285 are 'string'?
if so, try this ('alltrim' just in case):
delete tablename for not inlist(alltrim(Fieldname),'10005347797','1006009285')
else
just use without the single quotes
endif
Upvotes: 0