“variabel postgresql dalam kueri” Kode Jawaban

Postgres mendeklarasikan variabel

WITH myconstants (var1, var2) as (
   values (5, 'foo')
)
SELECT *
FROM somewhere, myconstants
WHERE something = var1
   OR something_else = var2;
Coding Cobra

variabel postgresql dalam kueri

-- 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

Jawaban yang mirip dengan “variabel postgresql dalam kueri”

Pertanyaan yang mirip dengan “variabel postgresql dalam kueri”

Lebih banyak jawaban terkait untuk “variabel postgresql dalam kueri” di Sql

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya