[Zope] SQL LIKE

JB jimbag@kw.igs.net
Wed, 12 Jan 2000 11:40:13 -0500


try this:

select * from annunci
where testo like '<dtml-var "'%' + firstword + '%'">'
and testto like '<dtml-var "'%' + secondword + '%'">'

cheers
jim

cesare@planningsrl.it wrote:
> 
> Hi all!
> 
> I would like to do a form in which the user can edit few words (separated
> by a blank character).
> 
> When the user press the "Search" button I would like to use those words to
> search in a field of a table.
> 
> I have done it but I have two  problems:
> 
> 1) I use sqlgroup but I can use it just with the = and not with the LIKE
> statement
> select  * from annunci
> <dtml-sqlgroup where>
>    <dtml-sqltest Parola column=testo type=string optional>
> </dtml-sqlgroup>
> 
> the result is:
> 
> select * from annunci
> where Parola="Word"
> 
> but I would like this result:
> 
> select * from annunci
> where Parola LIKE "%Word%"
> 
> 2) I am not able to divide the words in more conditions. I would like the
> following result:
> select * from annunci
> where testo LIKE "%FirstWord%" and testo LIKE "%SecondWord%"
>