create proc Check
@id int,
@type varchar(16)
asif(@type.equals("1")) ------这里应该怎么写?
begin
select * from Student where classID = @id
end
else
begin
select * from Student where gradeID = @id
end
SQL里面字符串的比较怎么写?
@id int,
@type varchar(16)
asif(@type.equals("1")) ------这里应该怎么写?
begin
select * from Student where classID = @id
end
else
begin
select * from Student where gradeID = @id
end
SQL里面字符串的比较怎么写?
列名 '1' 无效。
create proc Check
@id int,
@type varchar(16)
as
begin
if(@type=1) begin
select * from Student where classID = @id
end
else
begin
select * from Student where gradeID = @id
end
end
@id int,
@type varchar(16)
as if(@type='1') ------这里应该怎么写?
begin
select * from Student where classID = @id
end
else
begin
select * from Student where gradeID = @id
end
create proc Check
@id int,
@type varchar(16)
as
begin
if(@type=1)
begin
select * from Student where classID = @id
end
else
begin
select * from Student where gradeID = @id
end
end这么写就是对的,但是如果你的@type是由数字组成的话,加上单引号的话也是对的,(if @type=‘1’)
就看你的参数类型是什么了。如果是字符串,那么必须是用单引号的。
@type='1'(非数字型)sql 里面比较 没有c#的== 和 Java的equals!