我正在运行此查询
SELECT `contacts`.*
FROM `contacts`
WHERE
((email NOT LIKE '%domain1%') AND
(email NOT LIKE '%domain2%') AND
(email NOT LIKE '%domain3%') AND
(email NOT LIKE '%domain4%')
) AND (
DATE(created_at) = '2014-03-21'
)
结果是
=> [["ram.kumar@domain1.com", Fri, 21 Mar 2014 06:17:07 UTC +00:00],
["ram.kumar@domain2.com", Fri, 21 Mar 2014 17:05:21 UTC +00:00]]
问题
PS:查询结果未显示为MySQL输出,因为我从rails控制台运行它。
Contact.external.created_on( Time.parse("2014-03-21 ")).collect {|e| [e.email, e.created_at]}
答案 0 :(得分:1)
尝试使用OR
条件
SELECT `contacts`.*
FROM `contacts`
WHERE
(email NOT LIKE '%domain1%' OR
email NOT LIKE '%domain2%' OR
email NOT LIKE '%domain3%' OR
email NOT LIKE '%domain4%'
) AND (
DATE(created_at) = '2014-03-21'
)
"ram.kumar@domain1.com"
不是,NOT LIKE '%domain4%'
如果有意义