前两天在开发中遇到一个坑,本来我在快乐的做着增删改查,然后悲剧发生了,在查询数据库的过程中,报了java.sql.SQLSyntaxErrorException: 经过排查,是因为数据库表字段中存在关键字: 下面重点来了,我用的是mybatis-plus,我的解决方案如下: 在这个字段上增加@TableField(value="`key`")注解即可,用``将字段包起来,是英文半角状态下的数字1前面的那个符号. 再运行起来就没问题啦 one more thing: 1.如果你用的是jp
背景 开发过程中遇到了遇到了一句sql语句一直报错,看了一下字段名和表名都对应上了,但是还是一直报错 sql语句如下: update table set using = ""hh where id = 2 报错信息: [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax t
1.需求 在文本界面输入SQL语句,查询相应的数据,例如输入下面的语句 print(''' 支持大小写的SQL语句查询,大写或者小写都可以 1. select * from db1.emp 2. select * from db1.emp limit 4 3. select * from db1.emp where id > 24 4. select * from db1.emp where name like 李 5. select * from db1.emp where id > 10
数据库设计方面: 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描. 如: select id from t where num is null 可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: select id from t where num=0 3