“Variables PSQL Qith” Réponses codées

Variable postgresql dans la requête

-- 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)
Muddy Moose

Variables PSQL Qith

WITH vars AS (SELECT 42 AS answer, 3.14 AS appr_pi)
SELECT t.*, vars.answer, t.radius*vars.appr_pi
FROM table AS t, vars;
Obnoxious Oystercatcher

Réponses similaires à “Variables PSQL Qith”

Questions similaires à “Variables PSQL Qith”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code