Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update multiple rows with different values in one query in postgres #6983

Open
jeevanragula opened this issue Apr 22, 2024 · 0 comments
Open
Assignees
Labels
type:question general questions

Comments

@jeevanragula
Copy link

How to write below query in posrgres using GORM? Can some one help on this?
I don't see any documation in gorm for this type of query.
https://gorm.io/docs/update.html

update users as u 
set 
  email = u2.email,
  first_name = u2.first_name,
  last_name = u2.last_name
from (values
  (1, 'hollis@weimann.biz', 'Hollis', 'Connell'),
  (2, 'robert@duncan.info', 'Robert', 'Duncan')
) as u2(id, email, first_name, last_name)
where u2.id = u.id;

The document you expected this should be explained

Expected answer

@jeevanragula jeevanragula added the type:question general questions label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question general questions
Projects
None yet
Development

No branches or pull requests

2 participants