Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm trying to do a search by title and by content, but it gives an error syntax error at or near \"OR\

I’m trying to do a search by title and by content, but it gives an error

Typeorm

select
p.*,
from post p
left join vote v on p.id = v.post_id and v.user_id = $1
where p.is_published = true AND p.title ilike OR p.context::text ilike $2
limit 5 offset $3
const posts = await AppDataSource.query(`
  select
  p.*,
  from post p
  left join vote v on p.id = v.post_id and v.user_id = $1
  where p.is_published = true AND p.title ilike OR p.context::text ilike $2
  limit 5 offset $3
 `, [req.user.id, `%${req.query.q}%`, req.query.skip]
)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There’s a matching pattern missing:

p.title ilike OR p.context::text ilike $2
             ^ HERE
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading