Board index » delphi » Substring filter

Substring filter

In article <5013rk$...@news.sct.fr>, pbontant#nordmail.nordnet.fr@?.?
writes

Quote
>Hy,

>I'm trying to find the ability to filter a database according to
>substrings.

>I mean:
>I'd like to filter like this
>Filter := 'ri' in name

>so the following names would be selected :
>patrick
>   ^^

>richard
>^^

>Is it possible ?

Don't think so.

Are you able to use a Query instead of a Table?

If so you can use the LIKE operator in your WHERE clause

As in your example above

SELECT .... FROM tablename
WHERE Name LIKE '%ri%'

(% = percent sign incase it gets lost over news, it's the SQL equivalent
to the DOS *, or Paradox '..' ie a wildcard - zero or many characters)

Hope this helps.

--
Tim Stannard -  Ad Hoc Computing, Addlestone, Surrey, UK
                PC Consultancy, Engineering, Training
                Tel/Fax: 01932 830572  Mob: 0589 918184
                e-mail: stann...@adhoc.demon.co.uk

 

Re:Substring filter


Hy,

I'm trying to find the ability to filter a database according to
substrings.

I mean:
I'd like to filter like this
Filter := 'ri' in name

so the following names would be selected :
patrick
   ^^

richard
^^

Is it possible ?

TIA.

patrick Bontant

Re:Substring filter


Quote
pbontant#nordmail.nordnet.fr (patrick Bontant) wrote:
> Hy,

> I'm trying to find the ability to filter a database according to
> substrings.

> I mean:
> I'd like to filter like this
> Filter := 'ri' in name

> so the following names would be selected :
> patrick
>    ^^

> richard
> ^^

> Is it possible ?

Use (local) sql:
        select TheName
        from TheTable
        where TheName like '%ri%'

Happy programming!

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads