-- Oracle SELECTCASE WHENREGEXP_LIKE(field, '^[[:digit:]]+$') THEN field ELSE NULL END FROM DUAL; -- MySQL SELECTCASE WHENfield REGEXP '^[[:digit:]]+$'THEN field ELSE NULL END;
日期区间计算
Oracle日期区间计算,
1 2 3 4 5 6 7 8 9
SELECT A.* FROM A WHEREfield >= to_timestamp('2022-01-01', 'yyyy-mm-dd hh24:mi:ss') ANDfield <= to_timestamp('2022-09-30', 'yyyy-mm-dd hh24:mi:ss');
-- 等价于 SELECT A.* FROM A WHERE TO_CHAR(field, 'yyyy-mm-dd') BETWEEN'2022-01-01'AND'2022-09-30';
MySQL日期区间计算,
1 2 3 4 5 6 7 8 9
SELECT A.* FROM A WHEREDATE(field) BETWEEN'2022-01-01'AND'2022-09-30';
-- 等价于 SELECT A.* FROM A WHEREDATE_FORMAT(field, '%Y-%m-%d') >= DATE_FORMAT('2022-01-01', '%Y-%m-%d') ANDDATE_FORMAT(field, '%Y-%m-%d') <= DATE_FORMAT('2022-09-30', '%Y-%m-%d');