CREATE proc getbbsinfo
@interest_id int
as
select
i.interest_id,i.title,i.hf_id,i.updatetime,i.member_id,i.ipaddr,i.ontop,i.soul,i.main,i.bbs_type,
ci.picture,(year(getdate())-year(ci.birthday)) as age,ci.sex,ci.to_city_id,
li.loc_name,ci.user_type,ci.c_total
from
[interest] i left join ([club_interest] ci inner join [loc_info] li on li.loc_id=ci.to_city_id)
on ci.member_name=i.member_id
where interest_id=@interest_id or hf_id=@interest_id and del<>1 order by interest_id
GO========================================================执行这个存储过程巨耗资源 请问还有什么优化的语句
谢谢了........
@interest_id int
as
select
i.interest_id,i.title,i.hf_id,i.updatetime,i.member_id,i.ipaddr,i.ontop,i.soul,i.main,i.bbs_type,
ci.picture,(year(getdate())-year(ci.birthday)) as age,ci.sex,ci.to_city_id,
li.loc_name,ci.user_type,ci.c_total
from
[interest] i left join ([club_interest] ci inner join [loc_info] li on li.loc_id=ci.to_city_id)
on ci.member_name=i.member_id
where interest_id=@interest_id or hf_id=@interest_id and del<>1 order by interest_id
GO========================================================执行这个存储过程巨耗资源 请问还有什么优化的语句
谢谢了........
为什么不加条件
我觉得你把loc_info这个表作主表看看