select * from table_name a where a.name in (&入参) ______________取的是定值
if not object_id('Tempdb..T_20081010') is null drop table T_20081010 Go Create table T_20081010([ID] int,[S_ID] nvarchar(1),[P_ID] nvarchar(10)) Insert T_20081010 select 1,'a','2009-02-00' union all select 2,'a','2009-02-28' union all select 3,'b','2009-01-28' union all select 4,'b','2009-01-25' union all select 5,'b','2009-02-27' union all select 6,'b','2009-02-26' Go --Select * from T_20081010 declare @P int set @P='' select * from T_20081010 where (case when (id=@p) then 1 when @p='' then 1 else 0 end)=1
有好几个月没有来CSDN 了 没有orcle环境 用MS sqlserver 帮你实现一下
select * from table_name a where a.name=decode(param1,null,a.name,param1); 其中param1为参数!
select * from table_name a where a.name like '%$入参%'
请问怎么加$这个符号select * from table_name a where a.name=decode(param1,null,a.name,param1);
if not object_id('Tempdb..T_20081010') is null
drop table T_20081010
Go
Create table T_20081010([ID] int,[S_ID] nvarchar(1),[P_ID] nvarchar(10))
Insert T_20081010
select 1,'a','2009-02-00' union all
select 2,'a','2009-02-28' union all
select 3,'b','2009-01-28' union all
select 4,'b','2009-01-25' union all
select 5,'b','2009-02-27' union all
select 6,'b','2009-02-26'
Go
--Select * from T_20081010 declare @P int
set @P=''
select * from T_20081010
where (case when (id=@p) then 1 when @p='' then 1 else 0 end)=1
其中param1为参数!