一、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'
待續... ...