Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Multiple Searching

Author  Topic 

sp_wiz
Yak Posting Veteran

55 Posts

Posted - 2001-10-20 : 10:11:09
Hi

I seem to be hitting a brick wall with this. I am tying to write a sp that will allow me to search in numerous combinations.

Here's the code so far

declare @Photographer nchar(15)
declare @keywords nchar(255)
declare @photocategory nchar(15)

set @photosubcategory = null
set @photographer = null
set @photocategory = null
set @keywords = 'plant'



SELECT photos.trans_no, PicDesc, PHM_Name FROM PhotoGS_Main,photos,Picdesc
WHERE photos.trans_no = PicDesc.trans_no AND
PhotoGS_Main.Photog_ID = Photos.PH_Code AND
Photos.sub_code IN (Select sub_code from subject where text1 = COALESCE(@photocategory,text1)) AND
Photos.Sub_code = COALESCE(@photosubcategory,Sub_code) AND
Photos.PH_code = COALESCE(@Photographer, Photos.PH_code)AND
Photos.sub_code IN (Select sub_code from subject where text1 like '%'+@keywords+'%')

Everything works fine until i try to search using keywords, the other options are all from dropdown boxes on a page.

Can some one suggest where i am going wrong, or suggest an alternative..


Cheers Robp


   

- Advertisement -