Dev Helpers
← Back

Keep array elements at odd indexes

Keep array elements at odd indexes using SQLite JSON functions.

Open this example in the interactive library

Source code

SELECT key AS position, value FROM json_each('["ink","pen","pad","clip"]') WHERE key % 2 = 1 ORDER BY key;

Sample output

[
  {
    "position": 1,
    "value": "pen"
  },
  {
    "position": 3,
    "value": "clip"
  }
]