[Zope] sqltest vx. var
Doug Wyatt
doug@sonosphere.com
Sat, 10 Apr 1999 05:47:40 -0400
At 10:00 +0000 3/10/99, Tony McDonald wrote:
> Can #sqltest handle the 'wildcard' situation in MySQL (and probably
> other DBMSs too)
>
> select * from tbl where tbl_val like '%nib%' is a different SQL query from
> select * from tbl where tbl_val = 'niblet'
>
> my attempt...
>
> select *
> from tbl where
> <!--#sqltest tbl_val type=string multiple-->
Hi,
I just dug this up in the archive while realizing I want to do precisely
what you're asking: tbl_val like '%nib%'
I couldn't get your example to work. I ended up doing this:
select * from Book
<!--#sqlgroup where-->
<!--#if "_.len(xauthor)"-->
author LIKE <!--#sqlvar xauthor type=string-->
<!--#/if-->
<!--#and-->
<!--#if "_.len(xbookTitle)"-->
title LIKE <!--#sqlvar xbookTitle type=string-->
<!--#/if-->
<!--#/sqlgroup-->
order by author, title
where xauthor and xbookTitle are the arguments, and the caller has put '%'
on either end of them. I tried adding the '%'s in the SQL method, and this
worked when testing the SQL method, but not when it was called from my DTML
method.
Doug