Search Query in SQl server 2012
Posted on 2014-09-01
I have two tables Articles and Article_Keywords
Here is the table structure
1. ArticleID (PK)
1. ArticleKeywordID (PK)
Articles are to stored users article which has a title and a details field.
Article_Keywords is used to keywords for an article, it can be one or many for a single article.
Now, I need to give search feature to the users where user can search on article Keywords. Also there is a advance search option where they can search on keywords , title and details.
I am not good in writing sql queries
but what I was thinking of writing query for the first option (search only in keywords)
is select * from articles where articleid in (select articleid from Article_Keywords where keywords like %@parameters%)
And for the second part (search in keywords, title and details)
select * from articles where articleid in (select articleid from Article_Keywords where keywords like %@parameters%)
and title like %@parameters% and details like %@parameters%
I need know will these would be the best option to do search in these tables