Re: [Zope] Something funny about SQL like?
Well, I've tried escaping the '%', single quotes instead of double quotes, sqlvar instead of var, and none of those have worked. Here's the code again: select * from Users where <!--#var searchkey--> like "%<!--#var valuekey-->%" order by <!--#var searchkey--> And here's the error again: Error, exceptions.SyntaxError: unexpected token sequence.near :: 'where firstname'*' like "%Donald%' ******************************* current state = 45 expects: ',', 'UNION', 'FLOAT', 'GROUP', 'VARCHAR', 'DESC', 'SELECT', 'ORDER', 'WHERE', 'AS', 'IN', 'INTERSECT', 'ASC', '*', '+', '(', ')', '.', '/', 'EXCEPT', '-', 'AND', 'FROM', '*', ';', 'INTEGER', 'NOT', '>', 'OR', '=', 'BETWEEN', 'HAVING', '<', 'VALUES', ('nomatch1',) current token = ((-8, 'user_defined_name'), 'LIKE') SQL used: select * from Users where firstname like "%Donald%" order by firstname Like I said, it looks to me like the SQL it's trying to use is fine. Does GadflySQL not support the "like" keyword? Donner
hi dnald, here is a SQL "LIKE"-type query i use in my study project: < 8< gorgeous code 8< > <!--#if "colchoice1=='Customer Number'"--> Kunden.Kundennummer LIKE '%<!--#var input1-->%' <!--#/if--> < 8< gorgeous code 8< > as you can see, the whole %<!--#myvar-->% string is enclosed by single quotes. maybe that will help you. Jens Vagelpohl
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Donald Holten Sent: Monday, August 02, 1999 17:51 To: snair@utstar.com Cc: zope@zope.org Subject: Re: [Zope] Something funny about SQL like?
Well, I've tried escaping the '%', single quotes instead of double quotes, sqlvar instead of var, and none of those have worked. Here's the code again:
select * from Users where <!--#var searchkey--> like "%<!--#var valuekey-->%" order by <!--#var searchkey-->
And here's the error again:
Error, exceptions.SyntaxError: unexpected token sequence.near :: 'where firstname'*' like "%Donald%' ******************************* current state = 45 expects: ',', 'UNION', 'FLOAT', 'GROUP', 'VARCHAR', 'DESC', 'SELECT', 'ORDER', 'WHERE', 'AS', 'IN', 'INTERSECT', 'ASC', '*', '+', '(', ')', '.', '/', 'EXCEPT', '-', 'AND', 'FROM', '*', ';', 'INTEGER', 'NOT', '>', 'OR', '=', 'BETWEEN', 'HAVING', '<', 'VALUES', ('nomatch1',) current token = ((-8, 'user_defined_name'), 'LIKE')
SQL used:
select * from Users where firstname like "%Donald%" order by firstname
Like I said, it looks to me like the SQL it's trying to use is fine. Does GadflySQL not support the "like" keyword? Donner
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
At 23:50 02/08/99 , Donald Holten wrote:
Well, I've tried escaping the '%', single quotes instead of double quotes, sqlvar instead of var, and none of those have worked. Here's the code again:
select * from Users where <!--#var searchkey--> like "%<!--#var valuekey-->%" order by <!--#var searchkey-->
And here's the error again:
Error, exceptions.SyntaxError: unexpected token sequence.near :: 'where firstname'*' like "%Donald%' ******************************* current state = 45 expects: ',', 'UNION', 'FLOAT', 'GROUP', 'VARCHAR', 'DESC', 'SELECT', 'ORDER', 'WHERE', 'AS', 'IN', 'INTERSECT', 'ASC', '*', '+', '(', ')', '.', '/', 'EXCEPT', '-', 'AND', 'FROM', '*', ';', 'INTEGER', 'NOT', '>', 'OR', '=', 'BETWEEN', 'HAVING', '<', 'VALUES', ('nomatch1',) current token = ((-8, 'user_defined_name'), 'LIKE')
SQL used:
select * from Users where firstname like "%Donald%" order by firstname
Like I said, it looks to me like the SQL it's trying to use is fine. Does GadflySQL not support the "like" keyword? Donner
Nope. Like is not supported by Gadfly. The 'expects' list doesn't contain it, which could have been a clue =). -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn Pieters wrote:
At 23:50 02/08/99 , Donald Holten wrote:
Well, I've tried escaping the '%', single quotes instead of double quotes, sqlvar instead of var, and none of those have worked. Here's the code again:
select * from Users where <!--#var searchkey--> like "%<!--#var valuekey-->%" order by <!--#var searchkey-->
...
SQL used:
select * from Users where firstname like "%Donald%" order by firstname
Like I said, it looks to me like the SQL it's trying to use is fine.
In SQL _double_ quotes are used for escaping column names that are case sensitive or contain non-alpha characters. For strings you should use single quotes, so: select * from Users where firstname like '%Donald%' order by firstname Should do what you want --------- Hannu
participants (4)
-
Donald Holten -
Hannu Krosing -
Jens Vagelpohl -
Martijn Pieters