Postgresql 如何使用字符串到数组中的数组值连接到查找表
我有一张这样的动物桌:Postgresql 如何使用字符串到数组中的数组值连接到查找表,postgresql,Postgresql,我有一张这样的动物桌: Column | Type | Collation | Nullable | Default ------------------+--------------------------+-----------+----------+--------- animal_code | character varying(3) | | not null | animal_t
Column | Type | Collation | Nullable | Default
------------------+--------------------------+-----------+----------+---------
animal_code | character varying(3) | | not null |
animal_type_code | character(2) | | not null |
description | character varying(64) | | not null |
典型的内容可能是:
animal_code | animal_type_code | description
-------------+------------------+------------------------------
XAA | T | Not an animal, but a toaster
1 | D | This is a dog called Bob
2 | C | This cat is called Frank
3 | C | Wilf the cat has three legs
4 | D | Thunder is a dog
我正在使用的一个现有存储过程接收一个文本字符串,其中包含一个逗号分隔的动物代码值列表,如下所示:
Column | Type | Collation | Nullable | Default
------------------+--------------------------+-----------+----------+---------
animal_code | character varying(3) | | not null |
animal_type_code | character(2) | | not null |
description | character varying(64) | | not null |
商店宠物展示详情
“伦敦”,p_场馆VARCHAR64
“2019-12-03”,p_日期
“XAA,91,22,23,74,15,64,47,12”-p_参赛者文本
;
我正在使用unneststring_to_arraycode_csv,,'来提取动物输入代码
这可能很简单,但我只是想看看是否有参赛者的动物类型代码为T请注意这一点
选择动物代码、动物类型代码、描述
来自动物
内部连接选择从unneststring_到arrayp_entrants的trime entrant,,'t
关于动物_代码=进入者
其中,动物类型代码='T';