I have a form where a user can search for properties from a database. Everything is working except for the suburb search. I would like the user to be able to search for more then one suburb.
At the moment I have the information from the textbox being separated into individual ‘words’ and put into a variable @suburb_Statement which looks like:
For 1 word: @suburb_Statement = and ( suburb like 'word1' )
For 2 words: @suburb_Statement = and ((suburb like 'word1' ) or (suburb like 'word2' ))
What I need to do is get that variable into the WHERE statement in the code below but I’m not sure how to do that.
Any help would be great.
select
'ID: ' + uniqueID as uniqueID,
headline as headline,
subNumber as subNumber,
streetNumber as streetNumber,
street as street,
suburb as suburb,
'$' + convert (varchar (50),price,105) as price,
bedrooms as bedrooms,
bathrooms as bathrooms,
garages as garages,
description as description,
image1 as URL1,
category as category,
Ref_No as RefNo,
Rowguid
from Realestate
Where @RegID = 'Admin' and price >= @price_min and price <= @price_max
and bedrooms >= @bed and bathrooms >= @bath and garages >= @car