|
Posted by Igor on 03/29/06 13:27
I have one table with categories
tblCategories
cat_id | cat_name
-----------------
1 | cat 1
2 | cat 2
3 | cat 3
4 | cat 4
5 | cat 5
6 | cat 6
and one table with projects which relates to tblCategories
tblProjects
proj_id | proj_name | cat_id
----------------------------
1 | proj 1 | 2
2 | proj 2 | 2
3 | proj 3 | 3
4 | proj 4 | 2
How would you create stored procedure for searching some string in
filed proj_name but within multiple categories
for example
CREATE PROCEDURE [spSearch]
(
@SEARCH_STRING nvarchar(200),
@CAT_ID int
)
AS
BEGIN
SELECT proj_id
FROM tblProjects
WHERE (proj_name LIKE '%' + @SEARCH_STRING + '%') AND (cat_id =
@CAT_ID)
END
But that one works only with one categorie and i need to search for one
or more categories at once, does anyone have a solution? Is there
something like ellipsis (...) in C++ for MSSQL?
Navigation:
[Reply to this message]
|