lundi 29 novembre 2021

How to use ilike for phone number filter

Hi im fetching the user input and displaying the records that matches the condition, my query will look like

customers = customers.where('customers.contact_num ilike :search', {search: "%#{options[:search_contact]}%"})

here in db the contact number is stored in string with the format (091)-234-5678 like that

on while searching the user on basis of contact number if i search like this

091 it filters the number correctly, but while searching like 0912, it doesn't display record due to the braces, so how to modify the query to neglect the ) and - while searching.. As im new to the domain please help me out

thanks in advance

Aucun commentaire:

Enregistrer un commentaire