[Zope] ZSQL Like Statement

Behrens Matt - Grand Rapids Matt.Behrens@Kohler.Com
Mon, 22 Oct 2001 13:21:38 -0400


Mike Doanh Tran wrote:

> Hi all,
> 
> Does anyone know how to do a query in ZSQL with the "LIKE" statement?
> This is what i want to do:
> 
> select * from database where start_date LIKE '2001/10/%' ;
> 
> what is the ZSQL statement equivalent of mysql "LIKE" and the wild card 
> symbol?
> i have been searching for answers at Zope.org but found no luck.

I'm guessing you're talking about a Z SQL Method, which is just passed to the parser of your particular database, so it supports whatever your database does.


Also, I am assuming that START_DATE is a DATE type column.  If this is 
the case, you need to convert it to a string before doing that 
particular comparison.  At least, that's how it works in Oracle.

Try

	select * from table
	where to_char(start_date, 'YYYY/MM/DD')
	like '2001/10/%'

There is probably a better way to do that, but I usually defer 
SQL-writing to the local guru, since it never makes a whole lot of sense 
to me. :-)

-- 
Matt Behrens <matt.behrens@kohler.com>
System Analyst, Baker Furniture