[Zope-dev] ZSQL using LIKE operator

Casey Duncan cduncan@kaivo.com
Thu, 08 Feb 2001 09:11:01 -0700


Jens Vagelpohl wrote:
> 
> just write it out like:
> 
> SELECT * FROM table WHERE keywords LIKE '%<dtml-var name="my_var">%'
> 
> jens
> 
> on 2/8/01 7:17, Schmidt, Allen J. at aschmidt@nv.cc.va.us wrote:
> 
> > I have been through the docs, searched a variety of locations, and cannot
> > find anything on how to resolve a query which I need to read:
> >
> > SELECT * FROM table WHERE keywords LIKE '%keywords_variable%'
> >
> > <dtml-sqltest> has 'op=like' and when set to 'type=string' produces the LIKE
> > operation in the query, with single quotes,  but I cannot get it to 'wrap'
> > the keywords with the percent characters and THEN the single quotes to
> > produce that which I have in the query above.
> >
> > Ideally what I need to produce would be the query to search through some
> > text in several fields by the keyword_variable (IF any keywords are
> > provided) AND/OR within  a specific category of information. If I can get
> > the syntax to solve the above situation I think I can get <dtml-sqlgroup> to
> > sort out what information is provided and construct the query accordingly.
> >
> > Sorry for the length of this newbie question but I am stumped on this one.
> > And, so ends my lurking status.
> >
> > Thanks!
> > Allen
> >

SELECT * FROM table WHERE keywords LIKE '%<dtml-var name="my_var"
sql_quote>%'

would be a safer bet. Otherwise a value of my_var with a single quote in
it wouldn't work.
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>