svk
svk

Reputation: 4553

How to modify or run this query in foxpro?

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

Answers (3)

Ganapathy
Ganapathy

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

Frank Perez
Frank Perez

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

Manuel Arce
Manuel Arce

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

  • btw, English is not my 1st language

Upvotes: 0

Related Questions