为什么data.stackexchange.com上的this ridiculously simple query会在评论文本中返回不拥有[help/dont-ask]
的结果?我觉得我在这里错过了令人难以置信的东西。
select top 10 Id, PostId, Text
from comments
where text like '%[help/dont-ask]%'
我目前得到的结果:
Id PostId Text -- ------- ----------------------------------- 1 35314 not sure why this is getting downvoted -- it is correct! Double check it in your compiler if you don't believe him! 2 35314 Yeah, I didn't believe it until I created a console app - but good lord! Why would they give you the rope to hang yourself! I hated that about VB.NET - the OrElse and AndAlso keywords! 4 35195 I don't see an accepted answer now, I wonder how that got unaccepted. Incidentally, I would have marked an accepted answer based on the answers available at the time. Also, accepted doesn't mean Best :) 9 47239 Jonathan: Wow! Thank you for all of that, you did an amazing amount of work! 10 45651 It will help if you give some details of which database you are using as techniques vary. 12 47428 One of the things that make a url user-friendly is 'discover-ability', meaning you can take a guess at url's simply from the address bar. http://i.love.pets.com/search/cats+dogs could easily lead to http://i.love.pets.com/search/pug+puppies etc 14 47481 I agree, both CodeRush and RefactorPro are visually impressive (most of which can be turned off BTW), but for navigating and refactoring Resharper is much better in my opinion of using both products. 15 47373 Just wanted to mention that this is an excellent solution if you consider the problem to be linear (i.e. treating `A1B2` as a single number). I still think the problem is multi-dimensional, but I guess we'll just have to wait for the author to clarify :) 16 47497 Indeed, the only way to do this is get the server to generate your CSS file which can be done in many ways depending on which language you are using. HttpHandlers are common in C#. You could use jQuery or the likes to add styling to every element with the class 'ourColur' and parametrise your JS 18 47513 This advice goes against the spirit of CSS, which is separation of content and presentation. You way requires changing HTML for presentation sake, and stating in content which elements have same color.
...其中任何一个都不包含魔术链接(甚至是文本dont-ask
)。
答案 0 :(得分:2)
因为[]
分隔了一组要查找的字符。
您需要escape them。
或者只使用CHARINDEX
,因为搜索结果为unsargable。
WHERE CHARINDEX('[help/dont-ask]', text) > 0