Advanced Search for answers posted to your questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

This allows you to search all the answers posted to your questions or to the questions of any other user (you will need their UserId).

Stack Overflow

Q&A for programmers

/*
Use Search Parameters as follows :

- SearchTerm : Enter terms that you want to search for. Only limitation is that an exact search is performed so be careful when searching for multiple terms in a single query.  

NOTE :: If you do not want to search for a specific term, then fill this field a '%', without quotes 

- MinScore : The minimum score of the posts that you would like to search in.
- MaxScore : The maximum score of the posts that you would like to search in.
- IsAccepted : Set this to 1 when searching for only *accepted answers* to your questions. When searching for all answers, set it to 0 (default value).
- QuestionTags : This is an optional field. Leave it as is, if you do not need it. Otherwise, add search tags into this field. Again, since an exact match is performed, be careful of order and case when searching for multiple tags.
- SelfAnswer : Set this to 1 when searching for *your answers* to your questions. When searching for all answers, set it to 0 (default value).
*/


SELECT
        'site://a/' +  CAST(P1.Id AS nvarchar) + '|' + P2.Title as 'Post Link', 
        P1.Score as 'Score',
        P1.Body as 'Content'
       
FROM Posts as P1, Posts as P2
WHERE P2.Id = P1.ParentId and --Join of Questions with Answers--
      P2.PostTypeId = 1 and -- P2 Contains Questions --
      P2.OwnerUserId = ##UserId## and -- P2 contains posts of User --
      P1.PostTypeId = 2 and -- P1 contains Answers --
      
      -- Search Parameters --
      P1.Body like '%'+ ##SearchTerm:string## +'%' and --Searching Answer Body--
      P1.Score between ##MinScore:int?0## and ##MaxScore:int?1000## and --Searching Score--
      ( ( ##IsAccepted:int?0## = 1 and P1.Id = P2.AcceptedAnswerId ) 
      or ( ##IsAccepted## = 0 ) ) and --Searching based on accepted status--
      P2.Tags like '%' + ##QuestionTags:string?%## + '%' and --Searching based on question tags--
      ( ( ##SelfAnswer:int?0## = 1 and P1.OwnerUserId = ##UserId## ) 
      or ( ##SelfAnswer## = 0 ) ) --Searching in self answered--
      
      
ORDER BY Score desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached