You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vars_query_create_table1=`CREATE TABLE users ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`vars_query_create_table2=`CREATE TABLE users2 ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`// executing the querys one by one worksresult=awaitclient.execute(s_query_create_table1)result=awaitclient.execute(s_query_create_table2)// executing both querys at the same time does not work result=awaitclient.execute(`${s_query_create_table1};${s_query_create_table2}`)
the error is: INFO close connection error: Uncaught (in promise) Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; CREATE TABLE users2 ( id int(11) NOT NULL AUTO_INCREMENT, name varchar' at line 7 throw new Error(error.message);
The text was updated successfully, but these errors were encountered:
The error you're encountering is because the MySQL client for Deno does not support executing multiple queries at once. To create both tables, you need to execute the queries one by one, as you've already done successfully.
To create the tables, you can use the following code:
vars_query_create_table1=`CREATE TABLE users ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;vars_query_create_table2=`CREATE TABLE users2 ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;// Execute the queries one by oneresult=awaitclient.execute(s_query_create_table1);result=awaitclient.execute(s_query_create_table2);
As you can see, executing the queries one by one works, but combining them with a semicolon will result in a syntax error because the MySQL client for Deno does not support multi-query execution. If you need to execute multiple queries, you'll need to run them separately using the execute function for each query.
the error is:
INFO close connection error: Uncaught (in promise) Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; CREATE TABLE users2 ( id int(11) NOT NULL AUTO_INCREMENT, name varchar' at line 7 throw new Error(error.message);
The text was updated successfully, but these errors were encountered: