I am struggling yet again with SQL with my search function.
Basically I want a stored proc that splits up a string into words then for each word I want to check using Full Text Search if it is in any of 2 tables.
If results are found in these tables it should add them to any results it found for the other words and return a set where the record is in both these sets.
So here is my algorithm
if null return all restaurants
declare results = empty
for each word
if in restaurant.name or cuisine.name
addRowsToResults
else if in restaurant.city
addRowsToResults
else if in restaurant.postcode
addRowsToResults
addRowsToResults
results = (results + new results) where a match is in both
I have no idea where to start with this and I have searched google for ages but being a begginer in SQL I may be missing some terms.
Also is this even the best way to do this sort of thing?
Appreciate any help.
Edit: Just to give more info. City, Postcode and Name are all nvarchar fields in a Restaurants table. Cuisine name is in a different table and is linked through another table to restaurants as a restaurant can serve many types of cuisine.
All these fields have full text search indexing.