日期:2014-05-19  浏览次数:20509 次

哪位大侠来指点下!很简单的语法问题!
create   proc   [dbo].[HousingEstateInfo_Select]
(
@Community_ID   int,
@HousingEstate_ID   int,
@HousingEstate_Name   nvarchar(50),
@HousingEstate_Address   nvarchar(200)
)
as
select   distinct   HousingEstate_ID   ,HousingEstate_Name,   HousingEstate_Address,   Community_Name,  
from     CommunityInfo,HousingEstateInfo
where   (CommunityInfo.Community_ID   =   HousingEstateInfo.Community_ID)   and   (HousingEstateInfo.Community_ID   =@Community_ID)  
or   (@HousingEstate_ID   is   null   or   @HousingEstate_ID= ' '   or   (HousingEstate_ID   =   @HousingEstate_ID))
or   (@HousingEstate_Name   is   null   or   @HousingEstate_Name   = ' '   or   (HousingEstate_Name   Link   %@HousingEstate_Name%))
or   (@HousingEstate_Address   is   null   or   @HousingEstate_Address= ' '   or   (HousingEstate_Address   =   @HousingEstate_Address))

有语法错误,我不知道怎么改,一个是去除重复行,还有一个是动态的模糊查link

------解决方案--------------------
select distinct HousingEstate_ID ,HousingEstate_Name, HousingEstate_Address, Community_Name,
這一行的,號不要
------解决方案--------------------
create proc [dbo].[HousingEstateInfo_Select]
(
@Community_ID int,
@HousingEstate_ID int,
@HousingEstate_Name nvarchar(50),
@HousingEstate_Address nvarchar(200)
)
as
select distinct HousingEstate_ID ,HousingEstate_Name, HousingEstate_Address, Community_Name --多个逗号
from CommunityInfo,HousingEstateInfo
where (CommunityInfo.Community_ID = HousingEstateInfo.Community_ID) and (HousingEstateInfo.Community_ID =@Community_ID)
or (@HousingEstate_ID is null or @HousingEstate_ID= ' ' or (HousingEstate_ID = @HousingEstate_ID))
or (@HousingEstate_Name is null or @HousingEstate_Name = ' ' or (HousingEstate_Name like '% '+@HousingEstate_Name+ '% ')) --like写错
or (@HousingEstate_Address is null or @HousingEstate_Address= ' ' or (HousingEstate_Address = @HousingEstate_Address))

------解决方案--------------------
重复行试下left join