gpt4 book ai didi

sql - 使用 LIKE 运算符的订单结果

转载 作者:行者123 更新时间:2023-12-03 23:51:41 24 4
gpt4 key购买 nike

在 SQL Server 中,我可以使用这个 SQL 语句:

SELECT * 
FROM Customers
WHERE Country LIKE '%land%';

此查询将返回包含字符串 land 的值。

是否可以按字符串land的位置对返回值进行排序?

例子:

输入值:“新西兰、美国、Landcountry、Alandia”

输出值:“Landcountry, Alandia, New Zealand”

最佳答案

您可以使用 CHARINDEX

SELECT * FROM Customers
WHERE Country LIKE '%land%'
order by charindex('land', Country)

关于sql - 使用 LIKE 运算符的订单结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28169225/

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