0
內部情況下,當條件我執行select語句&如果回報什麼,然後我需要得到它的價值,但我得到的錯誤Postgres的 - 使用select語句中CASE WHEN
ERROR: missing FROM-clause entry for table "us"
查詢..
SELECT u.user_id,
CASE
WHEN
(SELECT us.attr_value
FROM user_setting us
WHERE us.user_id = u.user_id) IS NOT NULL THEN us.attr_value
ELSE
(SELECT gus.attr_value
FROM global_user_setting gus
WHERE gus.attr_key='key')
END
FROM user u
WHERE u.user_id IN (1,
2,3)
錯誤出現在IS NOT NULL THEN us.attr_value
我明白了這個問題,但找不到如何在select語句之外獲取該值?