简体   繁体   English

SIMPLE SQL选择查询位置

[英]SIMPLE SQL Select Where Query

Anyone got any idea why this doesn't work. 任何人都知道为什么这行不通。 Im at a loss 我无所适从

在此处输入图片说明

The following 下列

SELECT * FROM  tblCustomerDetails WHERE AccountNo='STO00900'

Returns nothing however if i run the same query with any othe accoutn number it works. 但是,如果我使用任何可用的编号运行相同的查询,则不返回任何内容。

and this account will show when i run 当我跑步时,此帐户将显示

SELECT TOP 10 * FROM tblCustomerDetails ORDER BY ID desc

Picture explains it better. 图片解释得更好。

Thanks 谢谢

Try as Notulysses suggested, but I would recommend it a bit differently: 按照Notulysses的建议尝试,但我会建议一些不同:

SELECT * FROM  tblCustomerDetails WHERE LTRIM(RTRIM(AccountNo)) = 'STO00900'

The LIKE operator will likely match more rows than you need (if te AccountNo column is not unique), so I'd go with trimming the whitespaces and then checking for a specific account. LIKE运算符可能会匹配比您需要的更多行(如果AccountNo列不是唯一的),因此我将修剪空白,然后检查特定的帐户。

条目的开头或结尾可能会有一些空间,请尝试修剪条目的两端。

Try 尝试

SELECT * FROM  tblCustomerDetails WHERE AccountNo LIKE '%STO00900%'

As there can be hidden characters. 由于可能存在隐藏字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM