如果我理解正确的话你的问题,你可以使用REPLACE函数是这样的:
SELECT title
FROM video
WHERE REPLACE(REPLACE(title, '-', ' '), '_', ' ') < 'video 03';
这将返回“视频01”,“视频-02”,“video_02”等。
编辑:你也可以利用这一点,也就是分隔标题从数字部分的字母数字部分:
select
title,
first_digit,
left(title, first_digit-1) as alphanumeric_part,
mid(title, first_digit, length(title)-first_digit+1) as digits
from (
select
least(case when locate('0', title)>0 then locate('0', title) else length(title)+1 end,
case when locate('1', title)>0 then locate('1', title) else length(title)+1 end,
case when locate('2', title)>0 then locate('2', title) else length(title)+1 end,
case when locate('3', title)>0 then locate('3', title) else length(title)+1 end,
case when locate('4', title)>0 then locate('4', title) else length(title)+1 end,
case when locate('5', title)>0 then locate('5', title) else length(title)+1 end,
case when locate('6', title)>0 then locate('6', title) else length(title)+1 end,
case when locate('7', title)>0 then locate('7', title) else length(title)+1 end,
case when locate('8', title)>0 then locate('8', title) else length(title)+1 end,
case when locate('9', title)>0 then locate('9', title) else length(title)+1 end) first_digit,
title
from
video
) video_pos
where mid(title, first_digit, length(title)-first_digit+1)+0 < 2
看到它here。
你或许应该使用一个“id”只是一个数字来识别视频,这似乎比你试图去做的更容易,更有效率。 –
你是一个杀手! ('INDEX'的*,顺便说一下':D' *)为什么你不使用主键? –
为什么你的问题是?你有什么尝试?你卡在哪里? – bidifx