问题描述
我有一个名为OrderNumber的字段,已经有一个字段值为JY8023的记录。我尝试使用此SQL代码进行查询,但是没有返回。
SELECT .... WHERE OrderNumber LIKEJY8023
我也尝试使用通配符,它的工作原理
SELECT .. .. WHERE OrderNumber像%JY8023%
那么这意味着 OrderNumber像JY9023 不一样, OrderNumber =JY8023 ?
字符串前后有字符,您看不到。尝试类似 select length(OrderNumber)WHERE OrderNumber像%JY8023%
以确认这一点。一些字符不仅不可见,而且不能用光标选择。但是,它们在那里,它们影响字符串比较。
其他调试步骤将是使用子字符串来提取违规部分,以及其他字符串函数进一步检查价值。喜欢,也许选择字符串作为十六进制编码字符串将帮助您识别字节。
I have a field called OrderNumber and there's already a record with that field value of "JY8023".
I tried querying using this SQL code, but it returned nothing.
SELECT .... WHERE OrderNumber LIKE "JY8023"
I also tried using wildcards and it worked
SELECT .... WHERE OrderNumber Like "%JY8023%"
So does that mean OrderNumber Like "JY9023" is not the same as OrderNumber = "JY8023"?
the string has characters before or after it, that you can't see. try something like select length(OrderNumber) WHERE OrderNumber Like "%JY8023%"
to confirm this. Some characters are not only invisible, but unselectable with a cursor. But, they're there and they affect string comparisons.
additional debugging steps to follow will be to use substring to extract the offending part, and other string functions to further inspect the value. like, maybe selecting the string as a hex encoded string will help you identify the bytes.
这篇关于类似谓词在SQL中如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!