我认为既然b表没有id列,就应该提示出错,即使不提示出错,也应该不删除任何记录,因为子查询的范围是空值。 如果修改一下delete a where id in (select id1 from b) ,这个语句是会提示没有字段id1。
终于等到Microsoft的回复Hi, The behavior you are seeing is by design. In the correlated subquery, if you do not qualify column references we will first try to bind the columns to the FROM clause in the subquery and if that fails we will try to bind to the FROM clause in the outer query. This is also according to ANSI SQL specifications and works pretty much the same in other database systems too. You have to use table aliases to write queries that doesn't result in such ambiguous behavior. See the KB article below for more details.http://support.microsoft.com/kb/298674-- Umachandar, SQL Programmability Team 由 Microsoft 在 2009/5/8 10:54 发送学习
如果修改一下delete a where id in (select id1 from b) ,这个语句是会提示没有字段id1。
The behavior you are seeing is by design. In the correlated subquery, if you do not qualify column references we will first try to bind the columns to the FROM clause in the subquery and if that fails we will try to bind to the FROM clause in the outer query. This is also according to ANSI SQL specifications and works pretty much the same in other database systems too. You have to use table aliases to write queries that doesn't result in such ambiguous behavior. See the KB article below for more details.http://support.microsoft.com/kb/298674--
Umachandar, SQL Programmability Team 由 Microsoft 在 2009/5/8 10:54 发送学习