Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #postgresql #variable #query
ADD COMMENT
Topic
Name
1+4 =