我需要在Postgres函数中为2变量赋值,如下所示.
a := select col1 from tbl where ... b := select col2 from tbl where ...
如何在一个行命令中为2个变量分配2个值?
喜欢
a,b := select col1,col2 from tbl where ...
如
“40.5.3. Executing a Query with a Single-row Result”所述(强调我的):
原文链接:https://www.f2er.com/postgresql/192254.htmlThe result of a sql command yielding a single row (possibly of multiple columns) can be assigned to a record variable,row-type variable,or list of scalar variables. This is done by writing the base sql command and adding an INTO clause.
@H_404_18@所以这应该工作:
SELECT col1,col2 INTO a,b FROM tbl WHERE...;