sql server数据库删除记录时使用别名

DELETE 语句用于删除表中的行。

语法如下

DELETE FROM 表名称 WHERE 列名称 = 值
  • 1

例如:

DELETE FROM user WHERE name = 'Wilson' 
  • 1

当表名使用别名时,语法如下

DELETE 别名 FROM 表名称 别名 WHERE 列名称 = 值
  • 1

例如:

DELETE t FROM user t WHERE name = 'Wilson' 
  • 1

如果写成

DELETE FROM user t WHERE name = 'Wilson' 
  • 1

会报以下错误

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server

猜你喜欢

转载自blog.csdn.net/weixin_39106371/article/details/80921419