且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

搜索记录包含逗号分隔的值,其中包含给定列表中的任何元素

更新时间:2022-12-09 23:35:01

Hope you have a good reason for such denormalization - otherwise it would be better to save the list to a child table.

Otherwise, querying would be complicated. Like:

  def days = [2,8,11]
  // note to check for empty days
  Schedule.withCriteria {
    days.each { day ->
      or {
        like('username', "$day,%") // starts with "$day"
        like('username', "%,$day,%")
        like('username', "%,$day") // ends with "$day"
      }
    }
  }

相关阅读

技术问答最新文章