• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

251
Views
ER_PARSE_ERROR - Node MySql

I am new to node and mysql. I am developing an API.

Here's the case:

I want to make a web service and make two insertions on two different tables with a single query.

    function createTask(taskInfo, callback) {
    return db.query(`start transaction;
    insert into task values(null,'${taskInfo.name}','${taskInfo.description}',${taskInfo.dueDate},'${taskInfo.difficultyId}','${taskInfo.course_id}') ;
    insert into evaluated_tasks (student_id, task_id)  
        (select id from user where type=1) , (select max(id) from task);
    commit;`
    , callback)
}

I am coming up with

ER_PARSE_ERROR

Update

I have two tables:

1) task (id, name, description, due_date, difficulty_id, course_id)

This table holds a list of tasks.

2) evaluated_tasks (student_id, task_id)

This table holds the tasks which are to be evaluated. When a task is evaluated for a specific student it has to be deleted from this table.

Now I want to create a new task. The thing is that after creating a new task then I have to insert to my evaluated_tasks table as many records as my students count. So each record will be a pair of two columns student_id and task_id.

The goal is to make all these on a single query. From my little research I saw I can use start_transaction and commit for mysql. The point is there might be a syntax error on this query.

about 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error