sql语句中 values值为什么要加单引号呢?
汪汪
汪汪 2016-12-20 16:53:03
0
2
1754

sql语句中 values值为什么要加单引号呢?values里面的放的本身就是PHP变量名字呀,双引号中可以解析变量值,为什么还要在变量中加单引号呢

汪汪
汪汪

reply all (2)
数据分析师

Why do values in sql statements need to be enclosed in single quotes? -PHP Chinese website Q&A-Why should single quotes be added to the values in the sql statement? -PHP Chinese website Q&A

Please watch and learn.

    阿神
    sql = "insert into user(name, age, class) values('李四', 18, '高三一班')";

    1 双引号中的是一个标准的SQL语句,把他拿到mysql中可以单独执行

    2 因为是SQL语句,字符型的字段的值要用单引号括起来加以标注

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!