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 ...
随机推荐
- C语言整数类型在X86和X64下的字节大小
C声明 32位机器(X86) 64位机器(X64) char 1 1 short int 2 2 int 4 4 long int 4 8 long long int 8 8 char * 4 8 f ...
- Codeforces 994A. Fingerprints
题意 从x数组中找到最多的y数组中有的数字,按在x数组中出现的顺序输出. 注意 这题x数组和y数组都不会出现重复数字. 代码 #include <bits/stdc++.h> using ...
- Fragment的理解
1.生命周期 启动Fragment时: onAttachonCreateonCreateViewonViewCreatedonActivityCreatedonStartonResume 启动后 ...
- mysql中间件研究(tddl atlas cobar sharding-jdbc)
mysql-proxy是官方提供的mysql中间件产品可以实现负载平衡,读写分离,failover等,但其不支持大数据量的分库分表且性能较差.下面介绍几款能代替其的mysql开源中间件产品,Atlas ...
- WCF(四)windows服务寄宿
WCF常用的寄宿方式除了IIS寄宿外,还有一种方式是寄宿到windows服务中,跟随系统启动而启动. 1.在项目中选择“添加”--“新建windows服务” 2.打开系统生成的设计界面的代码,引用“u ...
- 蓝桥杯_left and throw
思考了许久没有结果,最后,还是一位擅长搜索资源的学长帮我找到了一个不错的代码,这个代码极其精妙,再一次印证了一句话,没有做不到的,只有想不到的,当然这个代码我拿到手的时候是个没有注释的代码,我费尽周折 ...
- 使用剩余参数代替 arguments (prefer-rest-params)
使用剩余参数代替 arguments (prefer-rest-params) 剩余参数来自于ES2016.可以在可变函数中使用这个特性来替代arguments变量. arguments没有Array ...
- Unity 代码集锦之图片处理
1.将Texture2D保存为jpg void TestSaveImageToJPG(Texture2D buffer) { File.WriteAllBytes("F:/output.jp ...
- 【codeforces 810A】Straight «A»
[题目链接]:http://codeforces.com/contest/810/problem/A [题意] 有n门课的成绩,和一个整数k代表每门课的满分都是k分; 然后这n门课的成绩是按照平均分算 ...
- HDU 4318 Contest 2
简单的一题,使用类DIJK的算法就可以了. #include <iostream> #include <cstdio> #include <queue> #incl ...