multiple statements in one query doesn't works
See original GitHub issueIssue type:
[ ] question [X] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[X] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[] latest
[ ] @next
[x] 0.2.7
(or put your version here)
Steps to reproduce or a small repository showing the problem: Hello I would like to create a query with multiple statements like this:
queryRunner.query(`CREATE TABLE IF NOT EXISTS \`pool_${this.gameId}_${index + 1}\` ` +
`(\`id\` int NOT NULL AUTO_INCREMENT, ` +
`\`hash\` varchar(255) NOT NULL, ` +
`\`used\` boolean NOT NULL, ` +
`\`index\` int NULL, ` +
`PRIMARY KEY (\`id\`)) ENGINE=InnoDB; ` +
`CREATE TABLE IF NOT EXISTS` +
` \`available_pool_${this.gameId}_${index + 1}\` ` +
`(\`id\` int NOT NULL AUTO_INCREMENT, PRIMARY KEY (\`id\`)) ENGINE=InnoDB;`);
But i get error, if I copy that inside of mysql it executes the query correctly.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
SQL Query multiple AND and OR's not working - Stack Overflow
Look at this running sql fiddle based on your schema/data/query: ... deleted AS Hat_deleted FROM modx_hats WHERE published = 1 AND ...
Read more >Including multiple SQL statements in one query - IBM
You can include multiple SQL statements on the SQL query panel. The exceptions are CALL and CREATE PROCEDURE statements. These statements must be...
Read more >I get the "Multiple SQL statements in a single API call are not ...
Currently, a small workaround we have is to run a bash script that will submit the SQL files from the command line, but...
Read more >Best practices when working with Power Query - Microsoft Learn
It's entirely possible to create a single query that contains all the transformations and calculations that you may need. But if the query...
Read more >Is it possible to include multiple SQL-Statements in one query ...
Separating the two statements is not an option because the order in which they are processed matters and manipulating query order in Power...
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
What’s the need to create two tables in one statement? Can’t you just
In any case, it’s possible to do this if your driver supports it, though it’s not explicitly documented in typeorm. See https://github.com/mysqljs/mysql#multiple-statement-queries You can pass these params through typeorm to the driver via the
extra
property: http://typeorm.io/#/connection-options/common-connection-options I realize you’re using mssql, not mysql. I glanced at the mssql docs and didn’t see support for this, but I’m not familiar with the library. I recommend just using two statements. I don’t see anything in the code above that would prohibit this.Thank you @elthrasher, if I do that works:
I know that I can do query for each statements but I want to save queries.