[support] SQL Query - "LIKE" usage
Austin Einter
austin.einter at gmail.com
Fri May 20 01:08:58 UTC 2011
Hi All
I am using Drupal 6.20.
I have constructured below query.
str = *SELECT name, id, lft, rgt FROM resubmt_skill_ids AS node WHERE (
node.name LIKE "%sip%") ORDER BY node.lft*
Then I call db_query() API.
It did not return the expected records.
On debugging, looks the query went as
*SELECT name, id, lft, rgt FROM resubmt_skill_ids AS node WHERE (
node.nameLIKE "ip%") ORDER BY node.lft
*
Probably db_query API , considered %s as a string placeholder and removed
from query string.
Then I changed the query to
*SELECT name, id, lft, rgt FROM resubmt_skill_ids AS node WHERE (
node.nameLIKE "
%%sip%") ORDER BY node.lft*
Above query returns expected records.
My question is , when a token starts with "s", we will be facing above
issue.
What is the best way to resolve it.
Can I follow the mechanism, where tokens starting with "s", will be changed
to "%s" , so that in query the token will look like "%%s". Or do yo see any
issues with this approach.
Regards
Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110520/4c849f01/attachment.html
More information about the support
mailing list