select @no = @no select @center = @member_idselect @record_count=count(*) from av_accounts_main as a,av_member as b where a.owner_id = @no and b.manager_id = @center and a.store_flag='Y'
我想你是想查询的是某个字段中要含某个常量的记录,故可以这样修改语句: select @no = '常量值' select @no = '%' + @no select @center = '%' + @member_idselect @record_count=count(*) from av_accounts_main as a,av_member as b where a.owner_id like @no and b.manager_id like @center and a.store_flag='Y'
我觉得你的连接有问题, a,b两个表的关系是什么? 你的查询语句显示a,b是完全没有关系的表,所以在不加条件的情况下是总记录数=a的条数*b的条数 试试找出a,b间的关系用左联结select * from table1 a left join table2 b a.ID=b.ID
请大家帮忙
select @center = @member_idselect @record_count=count(*)
from av_accounts_main as a,av_member as b
where a.owner_id = @no
and b.manager_id = @center
and a.store_flag='Y'
select @no = '常量值'
select @no = '%' + @no
select @center = '%' + @member_idselect @record_count=count(*) from av_accounts_main as a,av_member as b
where a.owner_id like @no and b.manager_id like @center and a.store_flag='Y'
a,b两个表的关系是什么?
你的查询语句显示a,b是完全没有关系的表,所以在不加条件的情况下是总记录数=a的条数*b的条数
试试找出a,b间的关系用左联结select * from table1 a
left join table2 b a.ID=b.ID