Board index » delphi » searching text fields for partial matches anywhere in field

searching text fields for partial matches anywhere in field

I am trying to learn to develop a database by starting with a personal
reference database (to replace my 2500 entry venerable PCFile 7.0 database).

I have an authors field, title field, and keywords field plus several other
fields for identifying the journal or book.  All but the date field are
'text' fields.  I can use use the ADOtable1.Locate method to find an exact
match for say the authors field.  Simple enough.  But I often need to find
an article but can remember only one author or a single key word in the the
title.  How can I search a text field and retrieve records that contain the
search text anywhere in the searched field?

Paul Hewett
pk...@adelphia.net

 

Re:searching text fields for partial matches anywhere in field


You can try this:

  Locate('Name', VarArrayOf(['Dav']), [loPartialKey]);
                                      ^^^^^^^^^^^^^^^^
and you will find the first record with name 'David' or 'Davis' or ...

Quote
"Paul Hewett" <pk...@adelphia.net> wrote in message news:3ca13ceb_1@dnews...
> I am trying to learn to develop a database by starting with a personal
> reference database (to replace my 2500 entry venerable PCFile 7.0
database).

> I have an authors field, title field, and keywords field plus several
other
> fields for identifying the journal or book.  All but the date field are
> 'text' fields.  I can use use the ADOtable1.Locate method to find an exact
> match for say the authors field.  Simple enough.  But I often need to find
> an article but can remember only one author or a single key word in the
the
> title.  How can I search a text field and retrieve records that contain
the
> search text anywhere in the searched field?

> Paul Hewett
> pk...@adelphia.net

Re:searching text fields for partial matches anywhere in field


Use appropriate SQL  with wildcards e.g.

SELECT * FROM mytable WHERE mycolumn LIKE "%searched for text%"

will find those records with "searched for text" anywhere in mycolumn.

New to databases... find out about SQL.

Good luck!

Other Threads