创建员工信息表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. javascript中手风琴特效

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  2. 动态库连接器–动态库链接信息(Mach-O文件格式和程序从加载到执行过程)

    section cmd 说明 举例 __text 主程序代码   __stubs 用于动态库链接的桩   __stub_helper 用于动态库链接的桩   __cstring 常亮字符串符号表描述信 ...

  3. PhotoZoom安装之后没有快捷方式怎么解决?

    相信初次安装PhotoZoomPro的小伙伴都有这样的经历,就是软件安装完成之后桌面上并没有生成快捷方式,而且在所有程序里也找不到这个软件.这样的话,对于下次启动软件就相当困难了,甚至有些朋友为此又重 ...

  4. 面试题sql

    查询书的价格10到20 之前显示10to20 没有显示unknown CREATE TABLE book(price INT,NAME VARCHAR(20)) SELECT NAME AS '名字' ...

  5. php 与 nginx 的两种处理方式

    1.IP:Port 监听方式 php-fpm docker pull PHP:2.4-alpine nginx.conf fastcgi_pass 127.0.0.1:9000; php-fpm 在容 ...

  6. 【 henuacm2016级暑期训练-动态规划专题 A 】Cards

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 很显然只要维护B,R,G的数量就好了. 可以很容易想到一个dfs(int a,int b,int c) 然后如果a+b+c==1,那 ...

  7. jvm 虚拟机参数_栈内存分配

    1.参数 -Xss 指定线程最大的栈空间,整个参数也直接决定了函数可调用的最大深度 2.测试代码 private static int count; public static void addCou ...

  8. 高级聚合函数rollup(),cube(),grouping sets()

       rollup(),cube(),grouping sets()   上面这几个函数,是对group by分组功能做的功能扩展. a.rollup()   功能:在原结果基础上追加一行总合计记录 ...

  9. DCL授权命令

    create user 用户名//创建用户    grant DBA to 用户名//授权    revoke //撤销权限

  10. 解析如何利用ElasticSearch和Redis检索和存储十亿信息

    如果从企业应用的生存率来看,选择企业团队信息作为主要业务,HipChat的起点绝非主流:但是如果从赚钱的角度上看,企业市场的高收益确实值得任何公司追逐,这也正是像JIRA和Confluence这样的智 ...