Reputation: 3
I'm wondering what problems I may not foresee by using this query:
SELECT *
FROM tanswer
WHERE CourseID LIKE '%%%' AND Q39 LIKE 'p' AND Q42 LIKE 'a' AND Q43 LIKE 'a'
In particular using '%%%'.
The reason being, I have a dropdown that would send a '%' and in the sql I enclose it with the other two % to search through a set of courses, this query leaving the courseID searching through all courses.
The recordset returned seems to work fine, but I'm not sure if there's anything I may not be seeing by using three %%% together. Is this a special use of wildcards that I've stumbled across?
Upvotes: 0
Views: 193
Reputation: 5005
These are equivalent:
CourseID LIKE '%%%'
CourseID LIKE '%%'
CourseID LIKE '%'
Which is why your query behaves as you expected it to.
Upvotes: 3
Reputation: 2365
You need to use ! to escape the inner %
: i.e. %!%%
see here
Upvotes: 0