在一个查询中更新表中的多行,并在postgres上重合

时间:2018-03-23 09:43:29

标签: sql postgresql

如何在一个查询中更新如下表:class Cat{ private: float weight; int age; public: float getweight(); bool compareweight(Cat*); }; Cat::getweight(){ return weight; } bool Cat::compareweight(Cat* other){ return weight > other->weight; } 。这有可能在postgres?

/opt/keycloak/bin/kcadm.sh create users/b33088e5-321e-4b2f-afa6-7dca1871084e/user-attributes -r master -s name=user-attributes -s 'config."appid"=["APP_ID"]'  -s 'config."tenantId"=["T0"]' -s 'config."ugId"=["Admin_UserGroup"]'

让我们说,我希望得到一个完成结果,如:

/opt/keycloak/bin/kcadm.sh create components -r master -s name=user-attribute -s providerId=user-attribute -s parentId=1295a70f-25f7-4e45-bcb8-285d750 1c6d9 -s 'config."appid"=["APP_ID"]'  -s 'config."tenantId"=["T0"]' -s 'config."ugId"=["Admin_UserGroup"]'

2 个答案:

答案 0 :(得分:0)

UPDATE table_name
SET ivalue = x ,bvalue = y
WHERE 'featureid' = n AND 'accountid' = n

答案 1 :(得分:0)

UPDATE table_name
SET 
CASE WHEN featureid = n AND accountid = n 
        THEN ivalue = x
CASE WHEN featureid != n AND accountid != n 
        THEN bvalue = y

我不确定这是否是设置bvalue的正确条件,因为在问题中不是很清楚