
Zitat von
kasu
Hi! Ich habe eine Array Column 'followed_profiles und möchte alle Rows, die darin den Wert 'xy' enthalten.
CREATE TABLE userprofiles
(
user_id character varying(64) NOT NULL,
email character varying(64),
followed_profiles character varying(64)[],
CONSTRAINT userprofiles_pkey PRIMARY KEY (user_id)
)
Die Abfrage
select * from userprofiles where followed_profiles @> ARRAY['xy']
liefert mir aber :
operator does not exist: character varying[] @> text[]
Was wäre richtig?
Danke und Gruss,
kasu
Code:
test=*# select * from userprofiles;
user_id | email | followed_profiles
---------+-------+-------------------
1 | bla | {foo,bar,zzz}
2 | bla | {foo,bar,xyz}
(2 rows)
test=*# select * from userprofiles where 'xyz' = any(followed_profiles);
user_id | email | followed_profiles
---------+-------+-------------------
2 | bla | {foo,bar,xyz}
(1 row) Andreas
Lesezeichen