Super Search

1

Please login or register to vote for this query.

(click on this box to dismiss)

Hey! This is just a branching out tree of parameters! With this, you can search almost anything you want! Instructions included as well as built in examples

Software Engineering

Q&A for professionals, academics, and students working within the systems development life cycle

DECLARE @SOMENOTGREENTEXTFORYOU int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU2 int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU3 int = 1234567890
/*
Instructions:
UserId:
- An ID to search posts/comments made by that id, etc -
= OPTIONAL, jType null OR the killswitch to not use =

SearchType:
- Type Of Search -
1: Search All Users
2: Search A ID (UserID required)

OrderType:
- Whether to order the results or not -
1: Orders by Score
2: Orders by Most Recent

Amount:
- Number of results to get -
Any number that is small, otherwise StackOverflow will just timeout.

PostType:
- Type of post to search -
1: Questions
2: Answers

MinScore:
- Minimum score of search -
= OPTIONAL, Type the killswitch in MinScore to not use any minimum score =

MaxScore:
- Maximum score of search
= OPTIONAL, Type the killswitch in MaxScore to not use any maximum score =

Killswitch:
- Type this into optional integers to disable them -
!: Set this to a uncommon number that no one writes, e.g. 12345 :!
*/
DECLARE @SOMENOTGREENTEXTFORYOU4 int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU5 int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU6 int = 1234567890
/*
Examples Of Usage

Find top 10 recent questions:
UserId null
SearchType 1
OrderType 2
MinScore 12345(ks)
Killswitch 12345
MaxScore 12345(ks)
Amount 10
PostType 1

Find the top 5 answers ever:
UserId null
SearchType 1
OrderType 1
MinScore 12345(ks)
Killswitch 12345
MaxScore 12345
Amount 5
PostType 2

Find the top ten answers of someone's account:
UserID: (their id, e.g. 5)
SearchType 2
OrderType 1
MinScore 12345(ks)
Killswitch 12345(ks)
MaxScore 12345(ks)
Amount 10
PostType 2
*/
DECLARE @SOMENOTGREENTEXTFORYOU7 int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU8 int = 1234567890
DECLARE @SOMENOTGREENTEXTFORYOU9 int = 1234567890

-- End of documentation --






-- Start of code --

DECLARE @UserId int = ##UserId##
-- PUT AS NULL IF YOU DONT KNOW --
if ##SearchType:int## = 1
  if ##OrderType:int## = 1
    if ##MinScore:int## = ##Killswitch:int##
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        ORDER BY Score DESC
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score <= ##MaxScore:int##
        ORDER BY Score DESC
    else
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score >= ##MinScore:int##
        ORDER BY Score DESC
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score >= ##MinScore:int##
        AND Score <= ##MaxScore:int##
        ORDER BY Score DESC
  else
    if ##MinScore:int## = ##Killswitch:int##
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score <= ##MaxScore:int##
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
    else
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score >= ##MinScore:int##
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int##
        AND Score >= ##MinScore:int##
        AND Score <= ##MaxScore:int##
else
  if ##OrderType:int## = 1
    if ##MinScore:int## = ##Killswitch:int##
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        ORDER BY Score DESC
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score <= ##MaxScore:int##
        ORDER BY Score DESC
    else
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score >= ##MinScore:int##
        ORDER BY Score DESC
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score >= ##MinScore:int##
        AND Score <= ##MaxScore:int##
        ORDER BY Score DESC
  else
    if ##MinScore:int## = ##Killswitch:int##
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score <= ##MaxScore:int##
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
    else
      if ##MaxScore:int## = ##Killswitch:int##
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score >= ##MinScore:int##
      else
        SELECT TOP ##Amount:int## *
        FROM POSTS
        WHERE
          PostTypeId = ##PostType:int## AND
          OwnerUserId = @UserID
        AND Score >= ##MinScore:int##
        AND Score <= ##MaxScore:int##

-- Changelog: --
/*
V0.1: 23/09/2018, added UserId, SearchType, OrderType, MinScore, Killswitch, Maxscore, Amount and PostType
*/

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results