当前位置:网站首页>解决:Unknown column ‘id‘ in ‘where clause‘ 问题
解决:Unknown column ‘id‘ in ‘where clause‘ 问题
2022-08-05 05:14:00 【运动猿】
小编给大家分享一下如何解决unknown column in where clause的问题,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
但凡写过sql语句的人估计都曾经碰到过类似于Unknown column ‘xxx’ in ‘where clause’的问题。 单从字面理解,我们很容易得出列名不存在的结论。这说明sql语句编写不正确,需要进行检查、修改。
但是,很多时候其实并不是由于列名出错造成的。
我总结了以下几点造成Unknown column 'id' in 'where clause'的原因,希望对大家有所帮助。
1.数据库字段名与实体类属性名不一致
相信大家平时都比较仔细,很少会产生这种问题,但有时候情况可能并不如意,数据库字段名可能会有空格,导致大家百思不得其解,小编今天就遇到了这种情况。


如图中所示,看似没什么问题,但却因字段名前面有空格,导致字段名与与属性名不一致,如果大家有遇到这种情况,希望对大家有所帮助。
2.由于拼凑sql语句时对字符类型数据没有用引号引起来造成的
例子:
String sql="select age from user where name="+xxx+";设置name的值为columName,则错误如下:
Unknown column ′xxx′ in ′where clause′解决步骤:
sql中如果name是整型的倒不会出现什么错误,而如果sql中字符串类型必须要包含在引号内。
所以修改sql为
String sql="select age from user where name=′"+xxx+"′";则错误消失。
边栏推荐
- pycharm中调用Matlab配置:No module named ‘matlab.engine‘; ‘matlab‘ is not a package
- ES6 Set、WeakSet
- What are the characteristics of the interface of the physical layer?What does each contain?
- 1.3 mysql batch insert data
- Lecture 2 Linear Model Linear Model
- shell函数
- 【MySQL】数据库多表链接的查询方式
- 2022牛客多校第四场C.Easy Counting Problem(EGF+NTT)
- [Go through 9] Convolution
- 学习总结day5
猜你喜欢

位运算符与逻辑运算符的区别

Convert the paper official seal in the form of a photo into an electronic official seal (no need to download ps)

数据库 单表查询

NodeJs接收上传文件并自定义保存路径

Flink 状态与容错 ( state 和 Fault Tolerance)

Database experiment five backup and recovery

CAP+BASE

server disk array

The difference between the operators and logical operators

【过一下6】机器视觉视频 【过一下2被挤掉了】
随机推荐
【过一下3】卷积&图像噪音&边缘&纹理
My 的第一篇博客!!!
【After a while 6】Machine vision video 【After a while 2 was squeezed out】
Distributed and Clustered
【过一下6】机器视觉视频 【过一下2被挤掉了】
[Software Exam System Architect] Software Architecture Design ③ Domain-Specific Software Architecture (DSSA)
位运算符与逻辑运算符的区别
门徒Disciples体系:致力于成为“DAO世界”中的集大成者。
el-pagination分页分页设置
序列基础练习题
Returned object not currently part of this pool
数据库实验五 备份与恢复
拿出接口数组对象中的所有name值,取出同一个值
vscode+pytorch使用经验记录(个人记录+不定时更新)
Flink accumulator Counter 累加器 和 计数器
The software design experiment four bridge model experiment
redis cache clearing strategy
学习总结week3_1函数
Database experiment five backup and recovery
机器学习(二) —— 机器学习基础