Reputation: 912
I would like to write a SQL query in a SQL Server stored procedure so that the result will not have duplicate rows. I have a table containing the following fields
ArticleId, Topic, Introduction, ArticleText, TagsAndKeywords
(TagsAndKeywords
are some info to make search easier)
Suppose the user is giving a search for "Best practices in SQL".
Then the query should do
Topic
first, Introduction, TagsAndKeywords & ArticleText
Topic
, Introduction
, TagsAndkeywords
and ArticleText
I want to get a single table without duplicate rows. Please assist me to solve this
Thanks
Upvotes: 0
Views: 212
Reputation: 1218
User below mentioned query. Seems ArticleId is PK show including PK in the Select will again produce duplicate results.
Select Distinct Topic, Introduction, ArticleText, TagsAndKeywords From myTable Where ...
Cheers.
Upvotes: 0