I have this queries inside in a single query in my code:
INSERT INTO individual (email, last_name, first_name, phone_number, auth_string, seed,
suppress_email_sending, is_participant, org_id, suborgs, roles, initiation_date, created_at,
modified_at, created_by, modified_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, '?', '?', ?, NOW(),
NOW(), ?, ?);
SET @last_ind_id = LAST_INSERT_ID();
INSERT INTO `program` (program_name,
org_id, suborg_id, created_at, created_by, modified_at, modified_by) SELECT ?, ?, ?, NOW(),
?, NOW(), ? FROM DUAL WHERE NOT EXISTS (SELECT * FROM `program` WHERE program_name = ?
LIMIT 1);
SET @last_program_id = LAST_INSERT_ID();
INSERT INTO `ind_group` (ind_id,
program_id, iteration_id, org_id, suborg_id, created_at, modified_at, created_by,
modified_by) VALUES (@last_ind_id, @last_program_id, ?, ?, ?, NOW(), NOW(), ?, ?);
I'm using Node and mariaDB. When I run this query in phpMyAdmin it works perfectly, but in my code it returns this error:
errno: 1064,
sqlState: '42000',
sqlMessage: "You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the
right syntax to use near 'SET @last_ind_id = LAST_INSERT_ID();
INSERT INTO `program` (program_name, org...' at line 1"