Answers for "postgres variables"

SQL
0

postgres declare variable

WITH myconstants (var1, var2) as (
   values (5, 'foo')
)
SELECT *
FROM somewhere, myconstants
WHERE something = var1
   OR something_else = var2;
Posted by: Guest on April-06-2020
0

postgresql variable in query

-- with myVar as (select "any value really")
-- 		then, to get access to the value stored in this construction, you do
-- 			(select * from myVar)
-- for example

with var as (select 123)    
... where id = (select * from var)

-- You could event re-cast the value (e.g. from INT to VARCHAR) 
with var as (select 123)    
... where id = ((select * from var)::VARCHAR)
Posted by: Guest on October-30-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language