在Postgres中搜索整数数组 [英] Search in integer array in Postgres

查看:76
本文介绍了在Postgres中搜索整数数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有其他方法可以在Postgres的整数[] 列中搜索某个值吗?

Is there any other way to search for a certain value in an integer[] column in Postgres?

我当前安装的Postgres版本不允许 允许以下语句:

My currently installed Postgres version does not allow the following statement:

SELECT * FROM table WHERE values *= 10;

数组示例:

'{11043,10859,10860,10710,10860,10877,10895,11251}'
'{11311,10698,10697,10710,10712,10711,10708}'

该语句应返回数组包含'10710'。

The statement should return every row where the array contains '10710'.

推荐答案

对于相等性检查,您可以简单地:

For equality checks you can simply:

SELECT * FROM table WHERE 10 = ANY (values);

阅读有关手册中的任何/某些

这篇关于在Postgres中搜索整数数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆