【发布时间】:2012-09-27 23:06:41
【问题描述】:
给定一串电子邮件,例如:
emails = "atttt@bbb-inc.com, scott@sara.com, a@a.com, rasx@bo.com"
通过一个查询,我想返回所有匹配的用户记录,其中:
User.rb (id,email)
这是我的查询,但如果我将电子邮件设置为多个电子邮件,它不会返回结果:
User.where("email IN (?)", emails)
User Load (1.0ms) SELECT "users".* FROM "users" WHERE (users.deleted_at IS NULL) AND (email IN ('atttt@bbb-inc.com,, scott@sara.com, a@a.com, rasx@bo.com'))
=> []
有关如何更新此 User.where 查询以从提供的电子邮件中获取所有匹配用户的建议?谢谢。
【问题讨论】:
-
添加 postgresql 作为标签,因为那是我使用 rails 的数据库。
标签: sql ruby-on-rails ruby-on-rails-3 postgresql