首页 > 其他 > 详细

查询避免Unknown column ‘xxx’ in ‘where clause

时间:2020-01-16 01:09:52      阅读:132      评论:0      收藏:0      [点我收藏+]

问题:

单从字面理解,我们很容易得出列名称不存在的结论,

但是,很多时候并不是列名出错造成的,而是由于拼凑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+"‘";

则错误消失。

 参考;http://blog.sina.com.cn/s/blog_6870d1e00100k7fo.html

查询避免Unknown column ‘xxx’ in ‘where clause

原文:https://www.cnblogs.com/isme-zjh/p/12199296.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!