如何知道满足了多少个OR条件?
我如何知道我的哪个结果满足了多少个条件/
SELECT
[TITLE]
FROM
[M_TIPS]
WHERE
[TITLE] LIKE '%VALUE%' OR
[TITLE] LIKE '%SQL%';
如何知道哪个结果仅满足 1 个 OR 条件以及哪个结果满足两个条件。条件的数量不是静态的,它可以增加。
有人可以帮忙吗?
How can i know that which of my result has satisfied how many number of conditions/
SELECT
[TITLE]
FROM
[M_TIPS]
WHERE
[TITLE] LIKE '%VALUE%' OR
[TITLE] LIKE '%SQL%';
How to know that which of the result has satisfied only 1 OR condition and which of the result has satisfied both conditions. The number of conditions are not static, it can increase.
Can anyone please help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其添加到结果中:
Add that to the result:
如果使用 OR,WHERE 子句中的短路*可能会阻止任何匹配计数超过 1。
将匹配列表存储在表变量中然后对匹配进行计数怎么样?
Short circuiting in a WHERE clause *may prevent any match count exceeding 1 if you use OR.
How about storing your match list in a table variable then counting matches;
假设您使用编程语言根据需要生成条件来动态生成查询,那么我建议像这样生成查询:
Assuming you're using a programming language to dynamically generate the queries with the conditions generated as required, then I suggest generating the query like so: