使用UNION ALL时如何限制MySQL中的行

时间:2016-05-17 13:54:59

标签: mysql where union-all

我有以下查询

$query_string = '
          (SELECT advisorBITname AS bitName, advisorName AS fullName, includeInCache AS cacheInclude
          FROM advisors AS advisor
          WHERE advisor.cacheInclude = "1")
          UNION ALL
          (SELECT user_id AS bitName, user_name AS fullName, includeInCache AS cacheInclude
          FROM users AS user
          WHERE user.user_role != "S" AND user.user_status = "A" AND user.cacheInclude = "1")
          ORDER BY fullName
        ';

无论我尝试什么 - 使用parens;消除parens,将WHERE参数放在用户部分或包含WHERE ojn每个表 - 查询失败时始终使用Unknown column 'advisor.cacheInclude' in 'where clause'

请注意,顾问程序表上有includeInCache列,用户表上有includeInCache

0 个答案:

没有答案