i trying search in database see if string matches part of string in database. can match if 2 exact using ilike, when searching part of string not catch data contains it. here code looks query:
servicesstate = repo.all(from p in callme.service, where: ilike(p.locations, ^zip.state)) it match when values exact ("south carolina", "south carolina"), want match when ("located in south carolina", "south carolina")
thanks
you can use % syntax like/ilike:
servicesstate = repo.all(from p in callme.service, where: ilike(p.locations, ^"%#{zip.state}%")) note not work correctly if zip.state contains %. if can contain %, you'll have use ecto.query.api.fragment/1 query this.
Comments
Post a Comment