Unknown column 't_user.id' in 'where clause'(通过字段名删除不了数据)
创建员工信息表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'(通过字段名删除不了数据)的更多相关文章
- 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 ...
- 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 ...
- MySQL 1054错误 Unknown column .... in 'on clause'
ERROR 1054 (42S22): Unknown column ... in 'on clause' 原因: MySQL5.0 Bug, 要把联合的表用括号包含起来才行: 例: SELECT ( ...
- Column 'id' in where clause is ambiguous
1.错误描述 org.hibernate.exception.ConstraintViolationException: error executing work at org.hibernate.e ...
- mysql莫名报"unknown column ... in 'on clause'"
今天遇见个会诡异的问题 一个web程序本地调试的好好的,结果发布到服务器上程序就报错了,报"unknown column ... in 'on clause'",网上搜了下,说是m ...
- mysql—mysql查询语句提示Unknown column ‘xxx’ in ‘where clause’
运行结果中提示Unknown column 'xxx' in 'where clause'的问题.经过大神的指导,顿时明白其中缘由,如果sql中定义的类型是int型的可以不用加引号,但是如果是字符串类 ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'dd' in 'where clause'
今天在使用mysql数据库查找数据的时候报错,错误信息如下: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown co ...
- java.lang.Exception: 资源处理失败,失败原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column '?????‰' in 'where clause'
1:Unknown column '?????‰' in 'where clause',这个问题,百度一搜,挺多的,但是貌似好像没有解决我的问题.贴一下我是如何拼接sql的.解决这个sql拼接bug的 ...
- Unknown column in 'where clause'
Unknown column in 'where clause' 错误如题:Unknown column in 'XXX' 'where clause' 意思是:未知表名 排查 1,查表名是否有错 2 ...
随机推荐
- Code Snippet 插件 使用——代码高亮
Code Snippet 下载地址 下载后安装,重启windows live writer 插入-->CodeSnippet 将代码粘贴进去,如图: 代码效果: @Controllerpubli ...
- Unity 默认进入的scenes
1,如果有多个场景,那么第一个场景要放在最上边,(其他的也要加) 2,如果不添加,那么Unity会把当前打开的场景添加进来. 3,切换场景的代码 using UnityEngine.SceneMana ...
- GDB Layout
layout:用于分割窗口,可以一边查看代码,一边测试.主要有以下几种用法:layout src:显示源代码窗口layout asm:显示汇编窗口layout regs:显示源代码/汇编和寄存器窗口l ...
- 为什么使用GitHub
GitHub的特点: 1.开源式分布版本管理系统 2.开源项目集中的代码库 3.所有略有规模的公司都在使用 GitHub的功能介绍: 1.记录多个版本 2.查看历史操作,可以进行版本吧回退和前进的控制 ...
- 06 ASP.net
ASP.net 第一天 理解浏览器与服务器概念,与WinForm的区别. C# IIS(Internet Information Service) 互联网信息服务 Java(Tomcat) Php(A ...
- HDU 5288 OO’s Sequence [数学]
HDU 5288 OO’s Sequence http://acm.hdu.edu.cn/showproblem.php?pid=5288 OO has got a array A of size ...
- ES6 学习6 数组的扩展
本章学习要点: 扩展运算符 Array.from() Array.of() 数组实例的 copyWithin() 数组实例的 find() 和 findIndex() 数组实例的 fill() 数组实 ...
- 【洛谷4941】War2 状压Dp
简单的状压DP,和NOIP2017 Day2 找宝藏 代码几乎一样.(比那个稍微简单一点) f[i][j] ,i代表点的状态,j是当前选择的点,枚举上一个选到的点k 然后从f[i-(1<< ...
- T^T OJ 2144 并查集( 并查集... )
链接:传送门 思路:增加num[] 记录集合中的个数,maxx[] 记录集合中最大值,挺不错的并查集练习题,主要是 unite 函数里如何改变一些东西,挺好的题,能用C尽量不用C++,效率差蛮大的! ...
- 大数据相关文档&Api下载
IT相关文档&Api下载(不断更新中) 下载地址:https://download.csdn.net/user/qq_42797237/uploads 如有没有你需要的API,可和我留言,留下 ...