Guest User

Untitled

a guest
Nov 23rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. declare @themaid int = 1 ; -- themeID
  2. declare @trefwoord nvarchar(max) = '' ; -- search query
  3.  
  4. select p.*
  5. from tblProjecten p left join tblProjectenThema pt on p.projectId = pt.projectId
  6. where pt.themaId = coalesce(@themaid, pt.themaId) and
  7. p.naam like '%' + @trefwoord + '%' ;
  8.  
  9. declare @themaid int = 1 ;
  10. declare @studiegebiedid int = null ;
  11. declare @opleidingdtypeid int = null ;
  12. declare @doelgroepid int = null ;
  13. declare @organisatorid int = null ;
  14. declare @regioid int = null ;
  15. declare @trefwoord nvarchar(max) = '' ;
  16.  
  17. select p.*
  18. from tblProjecten p left join tblProjectenThema pt on p.projectId = pt.projectId
  19. left join tblProjectenStudiegebieden ps on p.projectId = ps.projectid
  20. left join tblProjectenOpleidingsType pot on p.projectId = pot.projectID
  21. left join tblProjectendoelgroep pd on p.projectId = pd.projectId
  22. left join tblProjectenOrganisator po on p.projectId = po.projectId
  23. left join tblProjectenRegio pr on p.projectId = pr.projectId
  24. where pt.themaId = coalesce(@themaid, pt.themaId) and
  25. ps.studiegebiedid = coalesce(@studiegebiedid, ps.studiegebiedid) and
  26. pot.opleidingsID = coalesce(@opleidingdtypeid, pot.opleidingsID) and
  27. pd.doelgroepId = coalesce(@doelgroepid, pd.doelgroepid) and
  28. po.organisatorId = coalesce(@organisatorid, po.organisatorId) and
  29. pr.regioId = coalesce(@regioid, pr.regioId) and
  30. p.naam like '%' + @trefwoord + '%' ;
Add Comment
Please, Sign In to add comment