[英]SQL Wildcards using %%%
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. 原因是,我有一个下拉列表会发送一个“%”,在sql中,我将其与其他两个%一起括起来以搜索一组课程,该查询保留了CourseID可以搜索所有课程。
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? 这是我偶然发现的通配符的特殊用法吗?
These are equivalent: 这些是等效的:
CourseID LIKE '%%%'
CourseID LIKE '%%'
CourseID LIKE '%'
Which is why your query behaves as you expected it to. 这就是为什么查询的行为符合预期的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.