Board index » delphi » How to Find a Substring into a .DBF field with Local SQL

How to Find a Substring into a .DBF field with Local SQL

Hi All!

I need to search a substring into a field inside a .DBF file,
using Local SQL.
I have a .DBF with a 2 fields, ZipCode (longint) and StateName
(String[40]), I want to make a search for a sigle word inside the
Statename, How can I do that with SQL statemens?

For example find the record "NEW YORK" when I enter "YORK" as substring.

I tried SELECT * FROM "BASE.DBF" WHERE Statename=:VAR1

beeng VAR1 the substring, but off course that only searchs an exact
value,
I read that Local SQL supports SUBSTRING(), but I don't how to use it.

Thanks for your help  
---
                  Martin Cativa Gronda
     )|(          E-mail: moon...@satlink.com                  
    (o o)         Cordoba - ARGENTINA  
-ooO-(_)-Ooo-------------------------------------

 

Re:How to Find a Substring into a .DBF field with Local SQL


In article <327BEAAA.2...@satlink.com>, From Martin Cativa Gronda
<moon...@satlink.com>, the following was written:

Quote
> For example find the record "NEW YORK" when I enter "YORK" as
> substring.

> I tried SELECT * FROM "BASE.DBF" WHERE Statename=:VAR1

> beeng VAR1 the substring, but off course that only searchs an exact
> value,
> I read that Local SQL supports SUBSTRING(), but I don't how to use it.

Try using LIKE:

SELECT * FROM "Base.dbf" WHERE Statename LIKE "%YORK%";

God Bless,

--
Jay Schwisow
supp...@outinfront.com
---------
Frontline Software Technology, Inc.
http://www.outinfront.com

Re:How to Find a Substring into a .DBF field with Local SQL


Hi, Martin !

Martin Cativa Gronda <moon...@satlink.com> wrote:

Quote
>For example find the record "NEW YORK" when I enter "YORK" as substring.
>I tried SELECT * FROM "BASE.DBF" WHERE Statename=:VAR1

Try

        SELECT * FROM "BASE.DBF"
        WHERE StateName LIKE ( '%'+:VAR1+'%' )

Regards,

                                               Manuel Cuevas
                                  wwwmas...@mbytesl.com

        Manuel Cuevas

    wwwmas...@mbytesl.com
    http://www.mbytesl.com

  100115....@compuserve.com

   CIS        : 100115,314
   Fidonet    : 2:345/606
   Virnet     : 9:341/302
   ClipperNet : 225:345/601

Other Threads