当要往有设置自增标识字段的表插入数据,并希望同时设置好自增字段的值时,可以在insert into 的SQL语句前后分别加上一句sql语句,SET IDENTITY_INSERT TableName ON和SET IDENTITY_INSERT TableName OFF //tb_Users 的id字段是种子为1的自增标识字段 SET IDENTITY_INSERT tb_Users ON if not exists(select * from tb_Users where id = 1) b…
修改前代码: select MAX (article_order) from mall_school_article where 1=1 and is_deleted = 0 and status = 1 and article_type = #{articleType,jdbcType=TINYINT} and section = #{section,jdbcType=TINYINT} 报错:FUNCTION dev_operation.MAX does not exist 原因:mysql在…
可以使用 ORACLE TRUNC()函数 来进行判断 表 A 日期字段 datetime 部分数据带时分秒,部分数据没有时分秒 select * from A where datetime = TRUNC(datetime) --不包含时分秒 select * from A where datetime <> TRUNC(datetime) --包含时分秒 也可以用 TRUNC() 函数来更新数据. TRUNC():类似截取函数,按指定的格式截取输入的数据. .[trunc(for date…
person类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClassLibrary1 { class Person { //这里是字段用来存储数据,private可写可不写 private string _name; int _age; char _gender; //这里是属性,本身没值…
很高兴今天学到了一种新方法. 数据库中字段类型为Long ,值可能为null,也可能是某一数.因此对该字段数值进行 +1操作时需要判断该值是null还是数值. 同时实现更新操作.具体如下: update content set hits = case when hits is null then 1 else hits+1 end where id= 123456 还有另外一种方式,先判断值,若为nul…