📜  查询中的 postgresql 变量 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:20.650000             🧑  作者: Mango

代码示例2
-- 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)