PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 24, 2022

[FIXED] how to update and append values to array in google spanner

 October 24, 2022     arrays, google-cloud-platform, google-cloud-spanner, sql, sql-update     No comments   

Issue

I have a column with data type Array(String) in spanner. How can I append value to an array for update queries

I'm able to update the values using this command

update CarTable set models = ["BMW","HONDA"] WHERE year = "2020"

But the problem with this update is it overrides the previous values. I want to append these values to the ones that are already present. Is there any command that takes care of this requirement?


Solution

You can use the ARRAY_CONCAT function for that:

update CarTable set models = ARRAY_CONCAT(models, ["BMW","HONDA"]) WHERE year = "2020"


Answered By - Knut Olav Løite
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing