Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to update in phoenix based on specific columns?

avatar
New Member

Hi,

I am trying to figure out a way to do the equivalent of below command in phoenix:

update ics_tag_list set targetColumn = concat( 'prefix', sourceColumn) where rig =somerig;

I know that Phoenix does not support update command to update rows. But how do I update rows without entering values of all the columns in the query as an upsert command? Even with the upsert select command, we can only select values from other tables but I am not able to think of a way to generate the equivalent of above query in Phoenix since my source and target columns will change upon selection in the UI.

1 ACCEPTED SOLUTION

avatar
Super Guru

You can specify the columns that you want to update as long as you have the primary-key constraint columns available.

> create table t(pk varchar not null primary key, col1 integer, col2 integer, col3 integer);
> upsert into t(pk, col2) values('a', 2);

When you provide fewer columns than the schema defines, the other columns will receive no new value. This is an equivalent operation to an "UPDATE" in a traditional RDBMS.

View solution in original post

1 REPLY 1

avatar
Super Guru

You can specify the columns that you want to update as long as you have the primary-key constraint columns available.

> create table t(pk varchar not null primary key, col1 integer, col2 integer, col3 integer);
> upsert into t(pk, col2) values('a', 2);

When you provide fewer columns than the schema defines, the other columns will receive no new value. This is an equivalent operation to an "UPDATE" in a traditional RDBMS.