I have the following code which inserts a "task" into a table with a value for the "task". I am trying to modify this statement to insert multiple values into multiple columns, but I cant seem to get it to work since I am unfamiliar with the format.
Can sombody show me how the can be modified to insert multiple values?
var item = this.$.newItem.getValue();
this.$.db.query( 'INSERT INTO tasks ( task ) VALUES ( ? )', { values: [ item ] } );
Thanks alot.
Not knowing what this javascript is actually doing makes it hard to answer this question, but suffice it to say the syntax for inserting values into multiple fields in a sql query is as follows
INSERT INTO tableName (col1, col2, coln) VALUES (val1, val2, valn)
As a total educated guess, I would say you're looking for
this.$.db.query( 'INSERT INTO tasks ( task, some_other_field ) VALUES ( ?,? )', { values: [ item, some_other_input ] } );
for each "?" in your sql query, you will need another parameter in the values
array.