Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to do an Update Query on one to many relationship tables. #1888

Unanswered
jaiswal-rishabh asked this question in Q&A
Discussion options

How do I write a query like below, using go-pg. I am trying to update child table records based on where clause both on child table and parent table columns. Working Postgres raw query is

UPDATE child_table ct
set col_ct_A = 'foo'
FROM parent_table pt where pt.id = ct.reference_id
and pt.col_pt_X = 'some_value' AND ct.id IN ('foo','bar') Returning ct.*;

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /