I am trying to do a search in which you can enter several search engines to form an AND-Condition. He should also search in different fields of the database.
So, for example:
you, when you enter Bill Seattle, you should get a record in which NAME corresponds to Bill and CITY corresponds to Seattle. You will not get any rows where only CITY matches Seattle.
Now this does not seem complicated, but it seems to me that it is more difficult than I thought. I came up with something like this:
SELECT * FROM ADDRESS WHERE
((NAME LIKE 'Bill%') OR (NAME LIKE 'Seattle%'))
AND
((CITY LIKE 'Bill%') OR (CITY LIKE 'Seattle%'))
This works well in our previous case, but suppose we add another field:
SELECT * FROM ADDRESS WHERE
((NAME LIKE 'Bill%') OR (NAME LIKE 'Seattle%'))
AND
((CITY LIKE 'Bill%') OR (CITY LIKE 'Seattle%'))
AND
((COMPANY LIKE 'Bill%') OR (COMPANY LIKE 'Seattle%'))
.
, ( ), - , -
((COMPANY LIKE 'Bill%') OR (COMPANY LIKE 'Seattle%'))
-, , .
Btw, MSSQL '05.