一、union 与union all的区别(mysql)
SELECT country FROM Websites
UNION ALL
SELECT country FROM apps
ORDER BY country;
UNION ALL
SELECT country FROM apps
ORDER BY country;
上面语句使用union all,返回的结果集是两个子集的所有记录,country有可能有重复值
SELECT country FROM Websites
UNION
SELECT country FROM apps
ORDER BY country;
UNION
SELECT country FROM apps
ORDER BY country;
上面语句使用union,返回的结果集是两个子集的记录去重后的结果,country没有重复值
二、oracle日期、字符串互相转化:
日期转字符串:effdt="2018-02-02 12:23:09" to_char(effdt,'yyyy-mm-dd')="2018-02-02"
to_char(effdt,'yyyy-mm')="2018-02"
to_char(effdt,'yyyy')="2018"
字符串转日期:(需要注意的是第二个参数必须和字符串的长度格式一致)
to_date('2018-06-26','yyyy-mm-dd')
三、截取字符串:
oracle:substr('abcdefg',2,3)='bcd'
mysql:substr('abcdefg',2,3)='bcd'
待续... ...