There is an array[10,20] and I want to know is it a subset of array[20,30,10] or not?

Examples:

[10,20] and [30,20,10] - yes
[10,20] and [10,30]    - no
[10,20] and [20,10]    - yes
[10,20] and [10,20]    - yes

closed as off-topic by a_horse_with_no_name, Clockwork-Muse, iandotkelly, Todd, Jan Doggen Feb 28 '14 at 10:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist" – a_horse_with_no_name, Clockwork-Muse, iandotkelly, Todd
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 'An array in PostgreSQL'?? Is this part of some code block? If not, what data structures are we talking about? – Jan Doggen Feb 28 '14 at 10:50
  • Thanks, I got the right answer below. – edem Feb 28 '14 at 14:42
up vote 7 down vote accepted

Like this,perhaps:

SELECT ARRAY[10,20]  <@ ARRAY[30,20,10];

http://www.postgresql.org/docs/current/static/functions-array.html

  • 1
    Thanks for the link! – edem Jan 4 '14 at 16:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.