gpt4 book ai didi

sql - 如何在 IF 语句中使用 LIKE 语句?

转载 作者:行者123 更新时间:2023-12-02 01:09:06 24 4
gpt4 key购买 nike

我需要能够检查变量内部是否包含特定的文本字符串。这是我现在拥有的:

--This sample always goes to the ELSE block.
IF( @name LIKE '%John%' )
BEGIN
--do one thing
END
ELSE
BEGIN
--do the other thing
END

最佳答案

不知道...对我有用

declare @name varchar(45)

set @name = 'johnson'

IF( @name LIKE '%John%' )
BEGIN
print 'like'
END
ELSE
BEGIN
print 'dislike'
END

关于sql - 如何在 IF 语句中使用 LIKE 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2686262/

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