I am trying to do a search engine, something like stackoverflow here. I need to select all rows that contain any of selected tags.
Table
RowID Question Tags
1 'who' 'C#'
2 'what' 'SQL'
3 'where' 'C#,PHP'
4 'when' 'PHP,SQL'
string[] myTags=new string{"c#","PHP'};
then my sql select statement something like this
Select * from table where Tags like myTags[]
I wish to have results like
RowID Question Tags
1 'who' 'C#'
3 'where' 'C#,PHP'
4 'when' 'PHP,SQL'
Of course I know this is syntactically incorrect that is why I am here.
Linq version:
Sql Version:
If one item can have too many tags, you should change a little your database design (adding relational table), it’s not a good way to have a string which contains too many tags.
Update:
For your current DB sample you can do this with linq: