创建员工信息表t_user

CREATE TABLE t_user(

  id INT PRIMARY KEY AUTO_INCREMENT,

  username VARCHAR(20) ,

  password VARCHAR(20) ,

  age int ,

  phone VARCHAR(20) ,

  email VARCHAR(20) ,

  is_Delete int

)DEFAULT CHARSET=UTF8;

往员工表中插入数据:

INSERT
INTO t_user
VALUES(null,'张三','123456',23,'110','11111@qq.com',1),(null,'历史','123456',23,'110','11111@qq.com',1),(null,'孙悟空','123456',23,'110','11111@qq.com',2),(null,'李白','123456',23,'110','11111@qq.com',2),(null,'八戒','123456',23,'110','11111@qq.com',2);

问题:发现用delete from t_user where id=6;这个语句删除不了,其它字段名也试过了也不行,如下:

mysql> select * from t_user;
+----------+----------------+----------------+-----------+-------------+--------------+-----------------+
|   id |   username |   password |   age |   phone |   email |   is_Delete |
+----------+----------------+----------------+-----------+-------------+--------------+-----------------+
| 1 | 唐僧 | 123456 | 23 | 110 | 11111@qq.com | 2 |
| 2 | 张三 | 123456 | 23 | 110 | 11111@qq.com | 1 |
| 3 | 历史 | 123456 | 23 | 110 | 11111@qq.com | 1 |
| 4 | 孙悟空 | 123456 | 23 | 110 | 11111@qq.com | 2 |
| 5 | 李白 | 123456 | 23 | 110 | 11111@qq.com | 2 |
| 6 | 八戒 | 123456 | 23 | 110 | 11111@qq.com | 2 |
+----------+----------------+----------------+-----------+-------------+--------------+-----------------+
6 rows in set (0.00 sec) mysql> mysql> delete from t_user where id=6;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from t_user where id=6' at line 1
mysql> delete from t_user where id='';
ERROR 1054 (42S22): Unknown column 'id' in 'where clause'
mysql> delete form t_user where id=6;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't_user where id=6' at line 1
mysql> delete from t_user where id=6;
ERROR 1054 (42S22): Unknown column 'id' in 'where clause'
mysql> delete from t_user where username='八戒';
ERROR 1054 (42S22): Unknown column 'username' in 'where clause'
mysql> delete from t_user where t_user.id=6;
ERROR 1054 (42S22): Unknown column 't_user.id' in 'where clause'
mysql>

然后发现是表中的字段名有空格,正常的没空格的如下:

mysql> select * from dept;
+----+--------+
| id | name |
+----+--------+
| 1 | 神仙 |
| 2 | 妖怪 |
+----+--------+

字段名出现空格的话,通过字段名进行数据操作的时候要给字段名添加单引号,如下:

mysql> delete from t_user where 'id'=6;
Query OK, 0 rows affected, 1 warning (0.07 sec)

Unknown column 't_user.id' in 'where clause'(通过字段名删除不了数据)的更多相关文章

  1. Unknown column 'a.root_id' in 'where clause'解决方法

    最近遇到一个问题, update  sy_user as a inner join sy_user_charge_log as b on b.username=a.username set recon ...

  2. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 't.statis_date'

    1.错误原因 [ERROR:]2015-04-18 13:20:31,883 [异常拦截] com.skycloud.oa.exception.ExceptionHandler org.hiberna ...

  3. MySQL 1054错误 Unknown column .... in 'on clause'

    ERROR 1054 (42S22): Unknown column ... in 'on clause' 原因: MySQL5.0 Bug, 要把联合的表用括号包含起来才行: 例: SELECT ( ...

  4. Column 'id' in where clause is ambiguous

    1.错误描述 org.hibernate.exception.ConstraintViolationException: error executing work at org.hibernate.e ...

  5. mysql莫名报"unknown column ... in 'on clause'"

    今天遇见个会诡异的问题 一个web程序本地调试的好好的,结果发布到服务器上程序就报错了,报"unknown column ... in 'on clause'",网上搜了下,说是m ...

  6. mysql—mysql查询语句提示Unknown column ‘xxx’ in ‘where clause’

    运行结果中提示Unknown column 'xxx' in 'where clause'的问题.经过大神的指导,顿时明白其中缘由,如果sql中定义的类型是int型的可以不用加引号,但是如果是字符串类 ...

  7. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'dd' in 'where clause'

    今天在使用mysql数据库查找数据的时候报错,错误信息如下: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown co ...

  8. java.lang.Exception: 资源处理失败,失败原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column '?????‰' in 'where clause'

    1:Unknown column '?????‰' in 'where clause',这个问题,百度一搜,挺多的,但是貌似好像没有解决我的问题.贴一下我是如何拼接sql的.解决这个sql拼接bug的 ...

  9. Unknown column in 'where clause'

    Unknown column in 'where clause' 错误如题:Unknown column in 'XXX' 'where clause' 意思是:未知表名 排查 1,查表名是否有错 2 ...

随机推荐

  1. Python3字符串 详解

    Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. Python 访问字符串中的值 P ...

  2. CSS3中的2D和3D转换知识介绍

    一  2D转换 转换是CSS3中具有颠覆性的特征之一,可以实现元素的位移.旋转.变形.缩放,甚至支持矩阵方式,配合即将学习的过渡和动画知识,可以取代大量之前只能靠Flash才可以实现的效果. 1.移动 ...

  3. Axios 网络请求组件封装 (鉴权、刷新、拦截)

    一.前言 注意:本教程需要你对axios有一定的了解,不适用于小白(只能借鉴,希望你能自己动手),注释都写的很清楚.此封装并非完整版,已进行部分删减修改操作,但仍然适用于大部分业务场景,如果不适用于你 ...

  4. 使用Storyboard实现复杂界面

    http://blog.csdn.net/guchengluoye/article/details/7472771 http://wangjun.easymorse.com/?p=1564 http: ...

  5. 【codeforces 799D】Field expansion

    [题目链接]:http://codeforces.com/contest/799/problem/D [题意] 给你长方形的两条边h,w; 你每次可以从n个数字中选出一个数字x; 然后把h或w乘上x; ...

  6. Xshell 安装 Xftp

    一.下载 Xftp 链接:https://pan.baidu.com/s/1dGeL2gD 密码:as9x 二.安装 Xftp 无脑下一步 三.点击 Xshell 上的新建文件传输 四.弹出 xftp ...

  7. Nutch命令大全

    Nutch采用了一种命令的方式进行工作,其命令可以是对局域网方式的单一命令也可以是对整个Web进行爬取的分步命令.主要的命令如下: 1. Crawl Crawl是"org.apache.nu ...

  8. BZOJ——1602: [Usaco2008 Oct]牧场行走 || 洛谷—— P2912 [USACO08OCT]牧场散步Pasture Walking

    http://www.lydsy.com/JudgeOnline/problem.php?id=1602 || https://www.luogu.org/problem/show?pid=2912 ...

  9. ABAP FIELD-SYMBOLS 有大作用- 将没有可改參数的增强出口变得也能改主程序的值了

    看下图代码: report  z_xul_test2 中 定义了 全局变量 G_DATA1 , 分别调用了 z_xul_tes1 中的 form  和 function zbapi_test , 这两 ...

  10. Cordova 5 架构学习 Weinre远程调试技术

    手机上的页面不像桌面开发这么方便调试.能够使用Weinre进行远程调试以方便开发.本文介绍windows下的安装与使用. 安装 使用npm安装.能够执行: ###npm config set regi ...