2

Using alasql, I'm trying to insert a value into an array that is a value of a property only if it doesn't already exist. It's set up like this:

[{"name": "Bob", "assocIDs": [1, 5, 10]}, {...}]

I'd like to be able to insert 6 into assocIDs only if it isn't already there, for instance. I've tried combinations of IF SELECT WHERE IN etc and can't seem to find the proper combination. Any hints on how to do this? For reference, I'm working strictly off JSON in browser.

I can do this the long way, select out the array, check it, insert if not there, and then update the record, but I'd like to do it properly.

linus72982
  • 1,418
  • 2
  • 16
  • 31
  • "I'd like to do it properly" => The proper way to do this would be to put assocID data into its own table – mathiasrw Mar 24 '16 at 18:37

0 Answers0