How do I escape % in Knex where like query?

后端 未结 6 1441
挽巷
挽巷 2021-01-18 00:09

I\'m using knex to generate my SQL queries. In knex documentation, it shows this

knex(\'users\').where(\'columnName\', \'like\', \'         


        
6条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 00:53

    I have not used knex in a while so I can not test this. But have you tried to literally escape %? I hope that is what you want.

    let term = "%something%"
    let parsedTerm = term.replace("%", "\%")
    console.log(parsedTerm);
    

    Tell me about that please.

提交回复
热议问题