Search in answers to my questions

1

Please login or register to vote for this query.

(click on this box to dismiss)

Cardano Meta

Q&A for users and developers of the Cardano cryptocurrency ecosystem

/*
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 = 217 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--
      P2.Tags like '%' + ##QuestionTags:string?%## + '%' and --Searching based on question tags--
      ( ( ##SelfAnswer:int?0## = 1 and P1.OwnerUserId = 217 ) 
      or ( ##SelfAnswer## = 0 ) ) --Searching in self answered--
      
      
ORDER BY Score desc

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results