How would I make it so that this query is case insensitive so it finds instances of "Hop" and "hop" even when the search query is only "hop"
const {
rows,
} = await db.query(
"SELECT * FROM course WHERE header LIKE '%' || $1 || '%'",
[req.body.searchbar]
);
Use ILIKE
:
SELECT * FROM course WHERE header ILIKE '%' || $1 || '%'
You can also express this with the ~~*
operator:
SELECT * FROM course WHERE header ~~* '%' || $1 || '%'