记录一些常用的函数
一,更新当前时间
mysql:
update sys_user set update_data =sysdate() where id=#{id}
db2:
update sys_user set update_data =TO_CHAR(current timestamp,'YYYY-MM-DD HH24:MI:SS') where id=#{id}
二,IFNULL() 函数
mysql:
select ifnull(batchNo,1) from sys_inputbatch where id=#{id}
db2:db2不支持ifnull函数,但可以用coalesce()函数替代
select coalesce(batchNo,1) from sys_inputbatch where id=#{id}
三,concat()函数(将多个字符串连接成一个字符串)
mysql:
mysql中concat(str1, str2,…),可以拼接多个字符串;如果其中有一个参数为null,其返回值也是null。
select concat('he','llo','wor','d') from sys_test
db2:
db2中concat(str1,str2)只允许有两个参数。遇到多个参数拼接时,可以嵌套使用。
select concat(concat(concat('he','llo'),'wor'),'d') from sys_test