Quick subquery ... query.

Hi there,

I have a small query with regards to FoxPro's subquery handling. In T & Oracle SQL the following query returns the data I require:

SELECT * FROM tableName

WHERE (SELECT count(fieldName) FROM tableName WHERE fieldName = 'testData') = 0

Whereas in FoxPro I'm getting the error "Queries of this type are not supported".

Ignoring the fact the query is pointless in its current form (I'll be replacing the select with insert logic) and keeping in mind I'm doing this via an OleDbDataAdapter through MS.Net, is this possible in FoxPro

Basically I'm looking at inserting records into a table if (and only if) certain fields don't appear in the existing data.

Thanks in advance for any info - nub.



Answer this question

Quick subquery ... query.

  • kzu

    Hi Nub,

    Does this work for you

    Create Cursor TableName (FieldName C(10))
    Insert Into TableName Values ("Hello")
    Insert Into TableName Values ("World")

    *-- 0 rows
    Select T1.* From TableName T1 ;
     Where Not Exists ;
     (Select T2.FieldName From TableName T2 ;
     Where T2.FieldName = "Hello")

    *-- All rows
    Select T1.* From TableName T1 ;
     Where Not Exists ;
     (Select T2.FieldName From TableName T2 ;
     Where T2.FieldName = "FoxPro")

     



  • Tracy - MSFT

    That's beautiful, cheers Cindy.
  • Quick subquery ... query.