zoukankan      html  css  js  c++  java
  • 查询避免Unknown column ‘xxx’ in ‘where clause

    问题:

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

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

  • 相关阅读:
    01Game
    面试题
    面试题
    面向对象笔记
    1212作业
    12011作业
    1210作业
    1206作业
    1205作业
    1204作业
  • 原文地址:https://www.cnblogs.com/isme-zjh/p/12199296.html
Copyright © 2011-2022 走看看