Is it possible to remove some elements in array?
Before removing elements Array1 is :
{1,2,3,4}
Array2 that contains some elements I wish to remove:
{1,4}
And I want to get:
{2,3}
How to operate?
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
Is it possible to remove some elements in array?
Array2 that contains some elements I wish to remove:
And I want to get:
How to operate? |
||||
Just use
Result:
You'll need to install the intarray extension if you didn't already. It adds many convenient functions and operators if you're dealing with arrays of integers. |
|||||||||||||
|
Use
You can use the query in an sql function:
|
|||
|
array_remove()
but unless you install theintarray
module you can't easily remove one array from another – a_horse_with_no_name Jun 20 at 8:52