如果我理解正確的話你的問題,你可以使用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