where 执行时候诡异的问题 Unknown identifier:
发布于 3 个月前 作者 hellohuyg 266 次浏览 来自 问答

SELECT corehr_employmentrecord_all.changetypeoid AS corehr_employmentrecord_all_changetypeoid ,max(corehr_employmentrecord_all.changetypealias) AS corehr_employmentrecord_all_changetypealias ,count(DISTINCT corehr_employeeinformation_all.userid) AS corehr_employeeinformation_all_count_userid FROM corehr_employeeinformation_all all LEFT JOIN corehr_employmentrecord_all using tenantid,userid WHERE corehr_employeeinformation_all.tenantid = 106996 AND corehr_employeeinformation_all.approvalstatus =‘4’ and (corehr_employmentrecord_all.startdate between ‘2018-05-24’ AND ‘2018-06-22’) AND corehr_employmentrecord_all.iscurrentrecord = 1 GROUP BY corehr_employmentrecord_all.changetypeoid ORDER BY corehr_employmentrecord_all.changetypeoid DESC

语句中的 (corehr_employmentrecord_all.startdate between ‘2018-05-24’ AND ‘2018-06-22’) 在执行的时候出错提示:Unknown identifier: corehr_employmentrecord_all. 以下情况可以执行通过: 1.去掉该过滤条件的话可执行通过 2.对表进行别名

问题一:为什么加上那个过滤条件出错? 问题二:另外执行的时候必须指定数据库吗?使用use 后再执行有时候也会出错

1 回复

貌似目前还不支持表的别名, 只能用**的字段进行where判断

回到顶部