I have a JSON column that might contain the string "attribute":"my_value" (among other JSON properties), this is the query I have to search for it:
SELECT 1
FROM TABLE
WHERE JSON_COLUMN REGEXP '"attribute":"?"'
The execQuery function adds an apostrophe to the parametrized string and this is the query that runs:
SELECT 1
FROM TABLE
WHERE JSON_COLUMN REGEXP '"attribute":"'my_value'"'
This is not a valid SQL query, how can I search for this parameter to get the rows that match this value?
I am using orm package for mysql (5.6) in nodejs, this is how I use it:
execQuery(MY_QUERY, [param1], (err, data) => {
if (err) {
return reject({
error: 'cannotFetch',
message: err
});
} else {
return resolve(data);
}
})