How can I dynamically create a query???
See original GitHub issueI need to build my query with a forEach loop, then pass to sql.query(query) but it’s not working. Any help?? If not possible with this package, can you point me in a direction where it is?
ie:
query = 'select id, name, ';
forEach(product => query += 'sum(case when ....);
query += 'from items where ...';
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Learn SQL: Dynamic SQL - SQLShack
Dynamic SQL is a programming technique you can use to build SQL statements as textual strings and execute them later.
Read more >Dynamic SQL Tutorial - Introduction, Examples and Query
How to use Dynamic SQL? · -- Start by declaring the Query variable and other required variables · DECLARE @SQL · DECLARE @variable1...
Read more >How to dynamically generate SQL query based on user's ...
I need to create a GUI, using which users can select several attributes which will be used to query the database to find...
Read more >Dynamic SQL in SQL Server - TutorialsTeacher
Dynamic SQL is a programming technique where you build SQL query as a string and execute it dynamically at runtime. It lets you...
Read more >Build dynamic query with values from search form - Office
Sometimes, you may want to create a form that serves as a search form. You want to be able to enter values on...
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 Free
Top 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
That is valid, too. But from OP’s post it looked like some fairly low level but simplistic CRUD usage. You can use
knex
and this library together which, from OP’s post, I concluded would probably be better.I’m on a bit of a tidying spree and trying to weed out bugs from “how do I do X”/general SQL questions/my environment config is wrong/poor bug reports, so apologies my first response wasn’t drafted with 100% nuance 🙂
No worries. Initial response updated.