Are inserts of values of a sub-select supported?
See original GitHub issueHi,
I’m trying to build a INSERT
query that would use values of a sub-query:
INSERT INTO entries (secret, sequence)
VALUES ('123', SELECT( COUNT(*) FROM entries WHERE secret='123'))
Passing a builder as a value of the sequence
field does not seem to do the job:
knex('entries').insert({
secret: '123',
sequence: knex('entries').select().where('secret', '123')
}).then(...);
Documentation does not mention this case either. Is it supported?
Issue Analytics
- State:
- Created 10 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How can I insert values into a table, using a subquery with ...
I have two tables in SQL Server: article; prices. Now I want to select a certain set of ids and insert some entries...
Read more >How to Use Subqueries in INSERT, UPDATE, and DELETE ...
Do you find subqueries useful in SELECT? Learn how to use them in INSERT, UPDATE, and DELETE and see how powerful your SQL...
Read more >INSERT with SUBQUERY in VALUES clause — oracle-mosc
i am reading everywhere that subquery cant be used in the value clause of an insert statement .
Read more >Are inserts of values of a sub-select supported? #121 - GitHub
Hi, I'm trying to build a INSERT query that would use values of a sub-query: INSERT INTO entries (secret, sequence) VALUES ('123', ...
Read more >Inserting records using subqueries - w3resource
In this page we are discussing, how to insert rows using INSERT INTO statement, where rows are results of a subquery, made up...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
for now you can do
but, I have a patch to support a builder. Thoughts @tgriesser? Also what was the reason for using clone() in toString()?
Fairly certain this is covered in 0.6 - let me know if that’s not the case.