如何使用“和” "或"如果条件在“if语句”中 [英] How to use "and" "or" with if condition in "if statement"
本文介绍了如何使用“和” "或"如果条件在“if语句”中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误
子查询跟随=,!=,<,< =,>,> =或者当子查询被用作表达式。
i am getting error
subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
AS
BEGIN
declare @under varchar(50)
set @under = (select Group_Name from tbl_AccountGroup where UnderGroup='Sales A/C')
IF @abc='insert' and (@Group_Name='Sales A/C' or @Group_Name=@under)
BEGIN
set nocount on;
DECLARE @Customer_Id int
declare @Group_Id int
insert into tbl_CustomerCreation select [Group_Id],@Customer_Name,@Account_No,@Email,
@Billing_Address,@Shipping_Address,@Phone_No,@Fax,@Date,@OB,@Nature1,@CB,@Nature2,@Description from
tbl_AccountGroup WHERE Group_Name =@Group_Name
SET @Customer_Id= SCOPE_IDENTITY();
END
推荐答案
从评论中,您试图填充
From the comments, you are attempting to populate
@under varchar(50)
有多个值。
这不起作用。
我建议创建一个变量表并用Group_Name值填充它(类似于你在另一个问题中所做的那样)。
with multiple values.
This will not work.
I suggest create a variable table and populate it with the Group_Name values (similar to what you have done in another question).
DECLARE @data TABLE (grp VARCHAR(100));
INSERT INTO @data
select Group_Name
from tbl_AccountGroup
where UnderGroup='Sales A/C'
使用表格检查表格中是否存在@Group_Name。
你应该是能够从这里弄明白。
Use the table to check if @Group_Name exists in the table.
You should be able to figure it out from here.
这篇关于如何使用“和” "或"如果条件在“if语句”中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文