MYSQL使用小记之IN查询排序与正则使用

IN查询排序:

select * from test where id in(3,1,5) order by find_in_set(id,’3,1,5′);
select * from test where id in(3,1,5) order by substring_index(‘3,1,2’,id,1);

正则使用:

SELECT COUNT(alarmID)
FROM Alarm
WHERE (CVE NOT RLIKE ‘^CVE-[0-9]{4}-[0-9]{4}$’ OR CVE IS NULL)

Leave a Comment

Your email address will not be published.

*