问题是如何在PostgreSQL的多级JSON列中搜索(使用LIKE
语句)。
我希望按name
搜索,en
或列支持的任何其他语言。
表:
places
-------
id ascii_name translations
dsrsfdsf be-namor { "en":{"locale":"en","name":"Namur"},"de":{"locale":"de","name":"Namur"},"bg":{"locale":"bg","name":"Намюр"} }
s3drs2es be-mouscron { "en":{"locale":"en","name":"Mouscron"},"pl":{"locale":"pl","name":"Mouscron"},"de":{"locale":"de","name":"Mouscron"} }
我刚刚找到了一种使用json_object_keys的方法,但它导致了一个错误,我无法在WHERE语句中使用set-returning函数。
SELECT * FROM places p WHERE p.translations->json_object_keys(p.translations)->'name' LIKE '%Namur%'
错误:
[0A000]错误:WHERE
中不允许设置返回功能
提前谢谢!