Created
February 15, 2018 22:39
-
-
Save mhkeller/4d5d5947d64616ded7bf558f73f476e8 to your computer and use it in GitHub Desktop.
Setting a variable in pgsql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- least onerous option from here https://stackoverflow.com/questions/1490942/how-to-declare-a-variable-in-a-postgresql-query#16552441 | |
set session my.vars.id = '%my_string%'; | |
SELECT | |
* | |
FROM | |
my_table | |
WHERE | |
field LIKE current_setting('my.vars.id')::text | |
OR other_field LIKE current_setting('my.vars.id')::text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment