功能 | MySQL | sybase |
拼接 | concat(a,b) | a+b |
判断为null | a is null | a=null |
判断不为null | a is not null | a!=null |
若为null,赋值‘’ | select ifnull(a,'') from table | select isnull(a,'') from table |
格式转换 | convert(a,char) convert(a,SIGNED) | convert(char,a) convert(int,a) |
获取时间 | select now() | select getdate() |
获取第一行数据 | select * from table limit 1 | select top 1 * from table |
时间差 | timestampdiff(day,time1,time2) | datediff(day,time1,time2) |
字符串长度 | length(str) | len(str) |
时间格式 | select date_format(StartTime,'%Y-%m-%d %H:%i:%s') | select STR_REPLACE(rtrim(convert(char,StartTime,111)),'/','-') +' '+(convert(char,StartTime,108)) 或者 20221112xxxxx 转1022-11-12 select convert (datetime,substring(dte,1,8),112) from table |
b表值赋值给a表 | update a join b on (关联条件) set a.name=b.name , a.age=b.age | update a set a.name=b.name , a.age=b.age from a,b where(关联条件) |
b表数据插入a表 | insert into a select *,*,* from b |