NYCPHP Meetup

NYPHP.org

[nycphp-talk] Escaping special character like *, + in sql where clause

SS sumisudhir at yahoo.com
Fri Oct 8 23:01:56 EDT 2004


I have tried that before. Not sure why it did not
work. Thanks for your help.

--- Daniel Convissor
<danielc at analysisandsolutions.com> wrote:

> On Fri, Oct 08, 2004 at 01:24:03PM -0700, Sumithra
> S.Nair wrote:
> >    How can I escape these characters in the sql
> where clause. 
> >  
> > Select * from table1 where name like 'John
> smith*'.
> > The * is part of the name itself.
> 
> % and _ are wildcard characters in LIKE predicates,
> not *.
> 
> Now, the trick is how to escape THOSE. :)  Here's
> what the SQL-99 
> standard says:
> 
>     select * from foo where cf like 'a^%%' escape
> '^'
> 
> You can pick any character you want for the escape.
> 
> It works for most DBMS's, though don't try it with
> SQLite.
> 
> --Dan
> 
> -- 
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S
>   C O M P A N Y
>             data intensive web and database
> programming
>                 http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335
> f: 718-854-0409
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
> 




More information about the talk mailing list