我试图使用node.js来创建一个mysql数据库和表.
我想要执行的查询是:
CREATE DATABASE NodeTest;USE NodeTest;CREATE TABLE tblUsers (userId varchar(32), userName varchar(255), friendlyUserName varchar(255));
Run Code Online (Sandbox Code Playgroud)
所以我一次执行更多查询.在MySqlWorkbench中,这工作正常.
在我的nodejs项目中,它说我的sql语句中存在语法错误.
我的节点代码:
mysqlConnection.query( 'CREATE DATABASE NodeTest;USE NodeTest;CREATE TABLE tblUsers (userId varchar(32), userName varchar(255), friendlyUserName varchar(255));' , function( oError ){
if ( oError ) throw oError;
console.log( 'Database created.' );
});
Run Code Online (Sandbox Code Playgroud)
为什么我不能在节点js中以这种方式使用我的查询,但语法在MySql工作台中工作正常?我错过了什么吗?
边注:
我使用node-mysql(https://github.com/felixge/node-mysql)进行我的mysql操作.
根据那里的文档,有可能联合查询,但文档中的示例只讨论选择查询.
我使用以下方法创建了自定义复选框/单选按钮:
<label class="container">One
<input type="checkbox" checked="checked">
<span class="checkmark"></span>
</label>
<label class="container">Two
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="container">Three
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="container">Four
<input type="checkbox">
<span class="checkmark"></span>
</label>
Run Code Online (Sandbox Code Playgroud)
/* Customize the label (the container) */
.container {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Hide the browser's default checkbox */
.container input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0; …Run Code Online (Sandbox Code Playgroud)