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

How to do SQL insert statement using query instead of values? #4038

Open
henrywoody opened this issue Apr 28, 2024 · 0 comments
Open

How to do SQL insert statement using query instead of values? #4038

henrywoody opened this issue Apr 28, 2024 · 0 comments

Comments

@henrywoody
Copy link
Contributor

henrywoody commented Apr 28, 2024

I have a feature that requires copying some values from one table into another and would like to perform this operation fully within the database for performance reasons, so I'll need to execute a statement like INSERT INTO "target" ("a", "b") SELECT "a", "b" FROM "source" WHERE .... Of course I can just run this in SQL directly, but I'd still like to use Ent for the filtering part so I can reuse existing logic.

Is there any way to do the INSERT ... SELECT ...-style query using ent?

Alternatively is there a way I can get convert an Ent query to a string and basically do:

`INSERT INTO "target" ("a", "b") ` + client.Source.Query().String()

Or another way entirely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant