sql 使用变量的方法


set @name = '%奥迪%'

select * from car where name like @name

set @user_id='1000555144';
set @id=(select id from customer where user_id =@user_id);

set @find='宝马'
if(@find='宝马')
begin
 print '宝马汽车'
 select * from Car where name like '%'+@find+'%' 
end
else 
begin
 print '其它汽车'
 select * from Car
end

其他见 https://www.cnblogs.com/woniu-net/p/4770312.html

SQL