我试试这个
SELECT elem
FROM jsonb_array_elements('["*", "12/05/2020"]'::jsonb) AS elem
WHERE elem::text != '*';
还有这个
SELECT * FROM (
SELECT elem::text
FROM jsonb_array_elements('["*", "12/05/2020"]'::jsonb) AS elem
) elems WHERE elem != '*'
还有
SELECT * FROM (
SELECT elem::text
FROM jsonb_array_elements('["*", "12/05/2020"]'::jsonb) AS elem
) elems WHERE elem::text != '*'
并期待所有情况下的结果
"12/05/2020"
。但是得到"*", "12/05/2020"
。
为什么?
事实上我已经找到答案了:
SELECT elem
FROM jsonb_array_elements('["*", "12/05/2020"]'::jsonb) AS elem
WHERE elem::text != '"*"';
您需要单引号和双引号!