子查询字段的来源


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

对于子查询,名称解析处理是从内部嵌套层向外进行的,若当天表中没有select引用的列,则会从上一层中引用出来,若上层都没有,就会报错。
SELECT *
FROM frmuser a(NOLOCK)
WHERE a.Account NOT IN( SELECT account –
FROM mdDepartment a1(NOLOCK)
)
-account在mdDepartment中不存在,会引用上层frmUser的account,故语句不会报错,为避免这种情况,最好在字段前加别名。