public bool f(int i) { string sql = "select count(*) from Table where 物料名称 in (select 物料名称 from Table where 标识='"+i+"' )"; 执行sql根据结果返回true or false }
用存储过程: CREATE PROCEDURE [pro] @id int, @Return bit out AS if exists(select * from (select 物料名称,count(物料名称) as Count from table where 标识 = @id) t where Count>1) set @Return = 1 else set @Return = 0
CREATE PROCEDURE [pro] @id int, @Return bit out AS if exists(select * from (select 物料名称,count(物料名称) as Count from table where 标识 = @id group by 物料名称 ) t where Count>1) set @Return = 1 else set @Return = 0
select 1 from table where 标识=输入值 group by 物料名称 having(count(*)>1)
CREATE PROCEDURE [pro] @id int, @Return bit output AS begin if exists(select 1 from table where 标识=@id group by 物料名称 having(count(*)>1)) set @Return = 1 else set @Return = 0 end
select distinct count(*) as num from table where id = 1 group by 物料名称 代码中循环一次 if num > 1 return true;
没什么难的。 select 标识, 物料名称, count(*) from 表 where 标识=1(输入值) group by 标识, 物料名称 having count(*)>1 如有记录,就是真,没记录,就是假
{
string sql = "select count(*) from Table where 物料名称 in (select 物料名称 from Table where 标识='"+i+"' )";
执行sql根据结果返回true or false
}
CREATE PROCEDURE [pro]
@id int,
@Return bit out
AS
if exists(select * from (select 物料名称,count(物料名称) as Count from table where 标识 = @id) t where Count>1)
set @Return = 1
else
set @Return = 0
@id int,
@Return bit out
AS
if exists(select * from (select 物料名称,count(物料名称) as Count from table where 标识 = @id group by 物料名称 ) t where Count>1)
set @Return = 1
else
set @Return = 0
select 1 from table where 标识=输入值 group by 物料名称 having(count(*)>1)
@id int,
@Return bit output
AS
begin
if exists(select 1 from table where 标识=@id group by 物料名称 having(count(*)>1))
set @Return = 1
else
set @Return = 0
end
代码中循环一次
if num > 1 return true;
select 标识, 物料名称, count(*) from 表
where 标识=1(输入值)
group by 标识, 物料名称
having count(*)>1
如有记录,就是真,没记录,就是假