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 ...
随机推荐
- Sphinx在windows下安装使用[支持中文全文检索]
原文地址:http://www.fuchaoqun.com/2008/11/sphinx-on-windows-xp/ 前 一阵子尝试使用了一下Sphinx,一个能够被各种语言(PHP/Python/ ...
- 用IIS怎样在局域网内建网站
IIS服务器组建一览 IIS(Internet Information Server,互联网信息服务)是一种Web(网页)服务组件,其中包括Web服务器.FTP服务器.NNTP服务器和SMTP服务器, ...
- 使用 chrome 扩展 Vimium 实现快捷键关闭其他标签页
Vimium 是一款很强大的键盘操作扩展,几乎所有的操作都可以使用键盘命令完成,还支持自定义按键. 其实 Vimium 很早就支持了关闭其他标签页这个操作,甚至还能关闭左侧标签页和关闭右侧标签页,只是 ...
- Qwiklab'实验-Hadoop, IoT, IAM, Key Management'
title: AWS之Qwiklab subtitle: 1. Qwiklab'实验-Hadoop, IoT, IAM, Key Management Service' date: 2018-09-1 ...
- node——Commonjs
ECMA只规范了js最近的一些能力,并没有规范当要用js写一个庞大的项目如果使用模块化开发. CommonJS规范了当我们想开发大型程序的时候如何模块化来开发,以及模块化的时候,不同文件的通讯. Co ...
- kafka内外网集群配置
linux下配置使用以第一台为例(先配置好jdk环境)1.解压kafka:2.10-0.10.1.12.修改zookeeper.properties 新增配置:maxClientCnxns=0 tic ...
- Java获取当天、本周、本月、本季度、本年等 开始及结束时间
package com.zhaochao.utils; import java.text.SimpleDateFormat; import java.util.Calendar; import jav ...
- Jquery学习总结(2)——jQuery Ajax用法详解
[详解]jquery ajax在web应用开发中常用,主要包括有ajax,get,post,load,getscript等这几种常用无刷新操作方法,下面来给大家介绍一下.我们首先先从最简单的方法看起. ...
- jvm 虚拟机参数_栈内存分配
1.参数 -Xss 指定线程最大的栈空间,整个参数也直接决定了函数可调用的最大深度 2.测试代码 private static int count; public static void addCou ...
- WinServer-授权规则
授权规则: 使用谓词可以限制网站只能使用某一种请求 来自为知笔记(Wiz)