I have one field & it has comma separated ID, so i want to find from that selected id, here is my code,
.get(function(req, res) {
knex.select('*')
.from('exam')
.whereRaw('? = any(regexp_split_to_array(student_id))', [req.params.id])
.then(function(rows) {
//return res.send(rows);
console.log(rows);
})
.catch(function(error) {
console.log(error)
});
});
===> while i am using KNEX it will give an Error Like this,
{ error: function regexp_split_to_array(text) does not exist
name: 'error',
length: 220,
severity: 'ERROR',
code: '42883',
detail: undefined,
hint: 'No function matches the given name and argument types. You might need to add explicit type casts.',
position: '37',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_func.c',
line: '523',
routine: 'ParseFuncOrColumn'
}
- in student_id column i have ID like this, 33,34,35,36
- in req.params.id i got only one single ID like, 35.
- so i want that rows which have included 35 ID, in Same Table.
===> So i want Only Two Rows (2,3) because it has Included ID = 35.