gpt4 book ai didi

SQL LIKE 没有返回正确的结果

转载 作者:行者123 更新时间:2023-12-04 23:28:06 24 4
gpt4 key购买 nike

我有一个包含 LastName 和 FirstName 的 Person 表。

考虑下面的记录

FirstName == 'Pete' and LastName == 'Aaaa'

当我运行以下选择语句时:

select * from Person where FirstName='Pete' and LastName like 'a%' -- 0 record returned
select * from Person where FirstName='Pete' and LastName like 'aa%' -- 1 record returned
select * from Person where FirstName='Pete' and LastName like 'aaa%' -- 0 record returned
select * from Person where FirstName='Pete' and LastName like 'aaaa%' -- 1 record returned

当我在 SQL Fiddle 中运行它时 - 每个选择都会返回 1 条记录,因为它应该 SQL Fiddle query

有人有什么想法吗?

最佳答案

试试这个

select * from Person where FirstName='Pete' and LastName collate Latin1_General_CI_AS like 'a%'
select * from Person where FirstName='Pete' and LastName collate Latin1_General_CI_AS like 'aa%'
select * from Person where FirstName='Pete' and LastName collate Latin1_General_CI_AS like 'aaa%'
select * from Person where FirstName='Pete' and LastName collate Latin1_General_CI_AS like 'aaaa%'

关于SQL LIKE 没有返回正确的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13307796/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com