我正在尝试创建一个子查询,但不幸地失败了。我的查询因此错误而失败...


  操作数应包含1列


我要查找的所有帐户的schickUpdatedDate字段在过去40天内具有日期值,并且在support_c字段中没有'Initial Waranty'或'None'作为值。

SELECT SQL_CALC_FOUND_ROWS * FROM accounts
LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c
WHERE schickUpdatedDate BETWEEN NOW() - INTERVAL 40 DAY AND NOW()IN
  (SELECT * FROM accounts_cstm WHERE support_c != 'Initial Waranty' OR support_c != 'None')
ORDER BY schickUpdatedDate ASC


上面的所有字段都在accounts_ctsm表中,如果出于其他目的而将accounts表联接到该表中。

最佳答案

如果我理解正确,那么您只想显示按3个条件过滤的合并输出。我认为您当时不需要子查询。

这样行吗?

SELECT *
FROM accounts
LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c
WHERE schickUpdatedDate >= (curdate() - interval 40 day)
and support_c <> 'Initial Waranty'
and support_c <> 'None'
ORDER BY schickUpdatedDate ASC;

10-07 13:20