1

I have a text array that's storing unique file urls. Is there a way to insert a url and ignore duplicate?

1 Answer 1

1

Storing URLs that you want to be unique in a text[] array is a really bad idea, but since you asked.

update my_table
   set file_urls = file_urls||'new_file_url_here'
 where id = <id>
   and not 'new_file_url_here' = any(file_urls)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Yes I know :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.