sql server查询以特定字符结尾的字符串为什么返回无结果?

2025-03-12 23:06:41
推荐回答(2个)
回答1:

  1. SQL 关键字或函数substring,charindex 

  2. 假如特定字符串结尾:'TEST'

  3. 声明一个表 A,有一个字段为a 类型为char(10)

  4. 假如存在一条记录:'100000TEST'

  5. select * from A where substring(a,7,4)='TEST'

  6. declare @a char(10)

  7. select @a=a from A

  8. if charindex('TEST' @a)>0 代表存在!

回答2:

SELECT customer .customer_name  
FROM customer 
WHERE customer_street like '%Hill%'


你看下这样写有没有结果,,,

目测你的hill后面好像有空格,,,你可以实际的看下数据