Linked Questions

2 votes
1 answer
2k views

Recently I've read Quantified Comparison Predicates – Some of SQL’s Rarest Species: In fact, the SQL standard defines the IN predicate as being just syntax sugar for the = ANY() quantified ...
Lukasz Szozda's user avatar
328 votes
8 answers
517k views

Using Postgres 9.0, I need a way to test if a value exists in a given array. So far I came up with something like this: select '{1,2,3}'::int[] @> (ARRAY[]::int[] || value_variable::int) But I ...
Mike Starov's user avatar
  • 7,466
268 votes
4 answers
296k views

I've got two postgresql tables: table name column names ----------- ------------------------ login_log ip | etc. ip_location ip | location | hostname | etc. I want to get every IP ...
stUrb's user avatar
  • 6,870
350 votes
3 answers
508k views

What is the difference between IN and ANY operator in PostgreSQL? The working mechanism of both seems to be the same. Can anyone explain this with an example?
mohangraj's user avatar
  • 11.4k
20 votes
4 answers
31k views

I'm trying to get rows where a column of type text[] contains a value similar to some user input. What I've thought and done so far is to use the 'ANY' and 'LIKE' operator like this: select * from ...
Jose Hermosilla Rodrigo's user avatar
14 votes
3 answers
25k views

Here's my function declaration and part of the body: CREATE OR REPLACE FUNCTION access_update() RETURNS void AS $$ DECLARE team_ids bigint[]; BEGIN SELECT INTO team_ids "team_id" FROM "...
nnyby's user avatar
  • 4,668
13 votes
4 answers
3k views

I want to pass a query in Django to my PostgreSQL database. When I filter my query using a large array of ids, the query is very slow and goes up to 70s. After looking for an answer I saw this post ...
poolet's user avatar
  • 371
7 votes
2 answers
8k views

I have a custom type CREATE TYPE mytype as (id uuid, amount numeric(13,4)); I want to pass it to a function with the following signature: CREATE FUNCTION myschema.myfunction(id uuid, mytypes mytype[...
Ryan Fisch's user avatar
  • 2,672
6 votes
2 answers
8k views

I'm struggling on what seems to be a ruby semantics issue. I'm writing a method that takes a variable number of params from a form and creates a Postgresql query. def self.search(params) counter ...
cat3045's user avatar
  • 295
10 votes
1 answer
6k views

I have a JSONB object in PostgreSQL: '{"cars": ["bmw", "mercedes", "pinto"], "user_name": "ed"}' I am trying to use values from the "cars" array inside it in the WHERE clause of a SELECT: SELECT ...
bjones1831's user avatar
3 votes
1 answer
4k views

I wrote an API using go and gorm that runs calculations on our database and returns the results. I just hit the parameter limit for an IN condition when using an aggregate. Example query: SELECT SUM(...
Jay Lane's user avatar
  • 1,401
4 votes
1 answer
3k views

I am using Postgres 9.2.24. I have a table named _order with about 100,000,000 rows. The table has a column named merged_id int8. About 2,000,000 of the _order rows have a merged_id value, the rest ...
yc l's user avatar
  • 55
0 votes
2 answers
15k views

Following tables: CREATE TEMPORARY TABLE guys ( guy_id integer primary key, guy text ); CREATE TEMPORARY TABLE sales ( log_date date, sales_guys integer[], sales smallint ); INSERT INTO guys VALUES(1,...
Wells's user avatar
  • 11k
1 vote
2 answers
3k views

I have a type as: CREATE TYPE status_record AS ( id bigint, status boolean ); A procedure that does some processing with an array of type as input parameter as: CREATE OR REPLACE ...
Vishnu G S's user avatar
2 votes
2 answers
4k views

I have found many Questions and Answers about a SELECT excluding rows with a value "NOT IN" a sub-query (such as this). But how to exclude a list of values rather than a sub-query? I want to search ...
Basil Bourque's user avatar

15 30 50 per page