Skip to content

Instantly share code, notes, and snippets.

@dsandip
Created January 17, 2019 08:38
Show Gist options
  • Save dsandip/c80dbccf7c1bcc00384c9d6170e13919 to your computer and use it in GitHub Desktop.
Save dsandip/c80dbccf7c1bcc00384c9d6170e13919 to your computer and use it in GitHub Desktop.
Custom functions: sample function - search_articles
CREATE FUNCTION search_articles(search text)
RETURNS SETOF article AS $$
SELECT *
FROM article
WHERE
title ilike ('%' || search || '%')
OR content ilike ('%' || search || '%')
$$ LANGUAGE sql STABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment