[Zope] ZSQL Like Statement
Joel Burton
joel@joelburton.com
Mon, 22 Oct 2001 15:46:51 -0400 (EDT)
On Mon, 22 Oct 2001, 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.
Umm, ZSQL just passes SQL to your database; there is no ZSQL language.
So -> use the SQL your database would use.
In some databases (notably MS Access), you can use a wildcharacter in
a date as you are; in most databases, you would use a date-specific
operator. (It's also _much_ faster as it can use indexes, etc.)
In PostgreSQL, for instance, if you want to find everyone who did
something between Oct 1, 2001 and Oct 31, 2001, you'd say:
SELECT * FROM TABLE WHERE start_date BETWEEN '10/1/2001' AND
'10/31/2001';
Sytax will vary a bit from DB to DB, but this is usually the best way.
--
Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant