By murph on
I am trying to include a WHERE %s LIKE in my db_query, but i end up with:
WHERE %s LIKE /"%%s%/" ...
How do you have a LIKE in a db_query...i'm presuming there must be a different way of doing it? TIA
I am trying to include a WHERE %s LIKE in my db_query, but i end up with:
WHERE %s LIKE /"%%s%/" ...
How do you have a LIKE in a db_query...i'm presuming there must be a different way of doing it? TIA
Comments
You need to use %% to create
You need to use %% to create a literal %.
Example:
db_query('select x from {table} where x like "%%%s%"', $string);%%
Thanks bro, that was a strange hour to understand why some part of the alphabet didn't worked.
thanks men
thanks men
Another way
If you define the thing you are search for like
and do your query something like
you get rid of the need for the pairs of % signs.