mysql语法
来源:互联网 发布:dfa算法 编辑:程序博客网 时间:2024/06/04 19:43
SELECT * FROM t_student WHERE 1=1 and stu_name LIKE %王%
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%王%' at line 1
注意字符是要带单引号的
SELECT * FROM t_student WHERE 1=1 and stu_name LIKE '%王%'
if(stuName != null && !stuName.equals("")) {
System.out.println("stuName:"+stuName);
sql.append("and stu_name like ?");
paramList.add("'%"+stuName+"%'");
}
if(stuName != null && !stuName.equals("")) {
System.out.println("stuName:"+stuName);
sql.append("and stu_name like ?");
paramList.add("%"+stuName+"%");
}
USERNAME="root";
PASSWORD="root";
DRIVER="com.mysql.jdbc.Driver";
URL="jdbc:mysql://127.0.0.1:3306/imooc_pager";
USERNAME="root";
PASSWORD="root";
DRIVER="com.mysql.jdbc.Driver";
URL="jdbc:mysql://127.0.0.1:3306/imooc_pager?useUnicode=true&characterEncoding=utf8";
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stu_name like '%王%'and gender = 1' at line 1
StringBuilder sql = new StringBuilder("select * from t_student where 1=1"); //??1=1
if(stuName != null && !stuName.equals("")) {
System.out.println("stuName:"+stuName);
sql.append("and stu_name = ?");
paramList.add("%"+stuName+"%");
}
if(gender == Constant.GENDER_MALE || gender == Constant.GENDER_FEMALE) {
System.out.println("gender:"+gender);
sql.append("and gender = ?");
paramList.add(gender);
}
System.out.println(sql);
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stu_name = 'h'and gender = 1' at line 1
StringBuilder sql = new StringBuilder("select * from t_student where 1=1"); // where1=1 后面得加空格跟其他条件隔开
StringBuilder sql = new StringBuilder("select * from t_student where 1=1 ");
类似文章:其他原因的
http://www.itnose.net/detail/982537.html
http://ask.csdn.net/questions/170059
http://blog.csdn.net/vanezuo/article/details/6686089
http://blog.sina.com.cn/s/blog_6d70461d01018xul.html
class Y {
public static void main(String[] args) {
String s = "hello";
if(s=="hello") {
System.out.println("==相等hello");
}
if(s.equals("hello")) {
System.out.println("equals相等hello");
}
String snew = new String("new");
if(snew=="new") {
System.out.println("==相等");
}
if(snew.equals("new")) {
System.out.println("equals相等new");
}
//==相等hello
//equals相等hello
//equals相等new
}
}
- MYSQL语法
- MYSQL语法
- mysql 语法
- mysql 语法
- MySql语法
- Mysql语法
- MYSQL--语法
- mysql语法
- mysql语法
- mysql 语法
- mysql语法
- MySQL 语法
- Mysql 语法
- mysql语法
- MySQL语法
- MySQL语法
- mysql语法
- mysql语法
- spring3.x企业应用开发 摘要
- Android 中CheckBox设置自定义图片
- 第四周项目6—— 多项式求和
- 分享一百套视频
- 写代码仅仅是“写”代码吗?
- mysql语法
- ExtJs教程----Ext.data.Model的Ajax
- 正则表达式入门级看懂语法
- Lucene入门教程(一)
- 微信小程序开发工具安装及破解
- 微信小程序开发教程(破解版IDE 无内测资格也可使用)
- 第四周项目5-循环双链表应用 .
- app崩溃
- Hibernate中hbm文件有关Set一对多级联