标签:
今天在SQLSERVER 2012中执行下面的SQL语句,发现UserProfile表和UserRole表的数据被全部删掉了,好奇怪。
DELETE FROM [dbo].[UserProfile] WHERE UserId=(select userId from dbo.[user] where username=‘admin0001‘)
DELETE FROM [dbo].[UserRole] WHERE UserId=(select userId from dbo.[user] where username=‘admin0001‘)
DELETE FROM [dbo].[User] WHERE username=‘admin0001‘
执行where条件的子查询select userId from dbo.[user] where username=‘admin0001‘,报错:Invalid column name ‘userId‘. 原来User表中叫Id,而不是userId,然而为什么编译器编译通过呢?而且竟然无视后面的where条件,执行不带where条件的。delete from [user]语句。
标签:
原文地址:http://www.cnblogs.com/sen068/p/5171471.html