问题:

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

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

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
猜你喜欢
  • 2021-07-25
  • 2021-11-24
  • 2022-12-23
  • 2021-12-07
  • 2021-11-13
  • 2022-12-23
  • 2023-02-22
相关资源
相似解决方案