是否有一种方法可以找到默认值,该值是像000/000/0或11111或99999相同数字的组合?

发布于 2025-01-23 20:46:53 字数 236 浏览 4 评论 0原文

我想在SQL数据库中找到相同数字的组合,例如0000000/000/0/01111199999等。

是否有办法在不进行硬编码的情况下找到这些值?

我目前正在做的是:

select * from XXXX where value = '000/000/0'

I want to find values in the SQL database that is a combination of the same number such as 0000 or 000/000/0 or 11111 or 99999 etc.

Is there a way to find these values without hardcoding?

What I am currently doing is:

select * from XXXX where value = '000/000/0'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙幽之幻 2025-01-30 20:46:53

一个简单的解决方案是删除字符串的第一个字符的所有实例,并检查结果是否是一个空字符串:

select *
from t
where replace(replace(str, '/', ''), substring(str, 1, 1), '') = ''

A simple solution is to remove all instances of first character of the string, and check if the result is an empty string:

select *
from t
where replace(replace(str, '/', ''), substring(str, 1, 1), '') = ''
一场信仰旅途 2025-01-30 20:46:53

尝试一下:

SELECT * 
FROM XXXX 
WHERE value IN ('000/000/0',11111,99999,0000)

如果您需要使用应用程序或其他第三方的填充列值。您可以使用以下的存储过程:

CREATE PROC dbo.usp_ListOfNumbers @NumberValues Nvarchar(200)
as
BEGIN
SELECT * 
FROM XXXX 
WHERE value = @NumberValues
END

仅使用

EXEC dbo.usp_ListOfNumbers @NumberValues = '000/000/0'

Try this on :

SELECT * 
FROM XXXX 
WHERE value IN ('000/000/0',11111,99999,0000)

If you need fill column values with application or other third-party. you can use stored procedure like below:

CREATE PROC dbo.usp_ListOfNumbers @NumberValues Nvarchar(200)
as
BEGIN
SELECT * 
FROM XXXX 
WHERE value = @NumberValues
END

for call just use

EXEC dbo.usp_ListOfNumbers @NumberValues = '000/000/0'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文