-1

My query was like:

let query = `SELECT id, name FROM students WHERE school_code = "${schoolCode}" AND name REGEXP "${text}" `;

And with params:

let params = [ schoolCode, text ];
let query = `SELECT id, name FROM students WHERE school_code = "?" AND name REGEXP "?" `

Model.dataSource.connector.query(query, params, (err, res) => {} );

And it wouldn't work

(Solution below)

Shani Kehati
  • 427
  • 5
  • 10

1 Answers1

0

I thought maybe it was the REGEXP but

The Solution Was:

to remove quotes around the question marks.

e.g., this worked:

let params = [ schoolCode, text ];
let query = `SELECT id, name FROM students WHERE school_code = ? AND name REGEXP ? `

Model.dataSource.connector.query(query, params, (err, res) => {} );
Shani Kehati
  • 427
  • 5
  • 10