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. Thanks for any suggestions.
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
On Mon, 22 Oct 2001, Mike Doanh Tran wrote: ...
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?
Mike, ZSQL statements are passed to the database (DBMS). So, whatever "statement syntax" is supported by your database will be the right syntax. You need to read the documentation for your particular DBMS to find out how to do "SELECT ... WHERE ... LIKE". Since this is not part of Zope, I am not surprised that you cannot find reference to this at Zope.Org. Hope that helps, Andrew --- Andrew P. Ho, M.D. OIO: Open Infrastructure for Outcomes www.TxOutcome.Org
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
participants (4)
-
Andrew Ho -
Behrens Matt - Grand Rapids -
Joel Burton -
Mike Doanh Tran