From: David Garamond <davidgaramond@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Array: comparing first N elements?
Date: Tue, 12 May 2009 15:05:28 +0700
Message-ID: <7c33d060905120105y74b0483eyf5d94c07912a0702@mail.gmail.com> (raw)
I have a "materialized path" tree table like this (simplified):
CREATE TABLE product (
id SERIAL PRIMARY KEY,
parents INT[] NOT NULL,
name TEXT NOT NULL,
UNIQUE (parents, name)
);
CREATE INDEX name ON product(name);
Previously I use TEXT column for parents, but arrays look interesting and
convenient so I'm considering migrating to arrays. However, how do I rewrite
this using arrays?
SELECT * FROM product
WHERE parents LIKE '0001/0010/%';
In other words, testing against the first N elements in an array.
Regards,
Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: davidgaramond@gmail.com
Subject: Re: Array: comparing first N elements?
In-Reply-To: <7c33d060905120105y74b0483eyf5d94c07912a0702@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox