search array field?

From: mhewii(at)qix(dot)net (Mark & Candice White)
To: pgsql-general(at)postgresql(dot)org
Subject: search array field?
Date: 2002-02-16 23:41:44
Message-ID: 5e09903c.0202161541.2f143753@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to do all the normal SQL stuff (SELECT,WHERE,ORDER BY)
on the elements of an array field.
I can not alter the schema, and the number of elements are
variable.

How do I do this?

table: name, data
"nameA",{"data1","data2"}
"nameB",{"data2","data3","data4"}
"nameC",{"data5"}

SELECT name, ?data? FROM table WHERE ?data? LIKE "data1" OR ?data? LIKE
"data2";

results=
nameA, data1
nameA, data2
nameB, data2

I am using PostgreSQL and PHP (the output is HTML).
I can get all the data, then pars it in php but that seems
like a wast of SQL, and impractical with any large number of records.
I would like to do it with as much SQL and little php as posible.

If this is a RTFM type question please tell me where in what M
to R.
Thank you.

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2002-02-17 00:56:10 Re: JDBC
Previous Message Michael Welter 2002-02-16 23:34:03 JDBC