1樓:網友
你的「中文」是固定旅伍碧的文字嗎?
下面拆舉的語句只支援9999以下的數字排序。
select id,col, right(col,length(col)-least(
if(locate('0',col) >0,locate('0',col),9999),if(locate('1',col) >0,locate('1',col),9999),if(locate('2',col) >0,locate('2',col),9999),if(locate('3',col) >0,locate('3',col),9999),if(locate('4',col) >0,locate('4',col),9999),if(locate('5',col) >0,locate('5',col),9999),if(locate('6',col) >0,locate('橘衡6',col),9999),if(locate('7',col) >0,locate('7',col),9999),if(locate('8',col) >0,locate('8',col),9999),if(locate('9',col) >0,locate('9',col),9999)
1) *1 a
from test4 order by a
2樓:海納百川文淵閣
order by 欄位名稱+0 desc/asc的形式進哪皮行排序order by 欄位沒備名稱*1 desc/asc的形式進行排序李察差。
3樓:杞寄文
select id, col,length(col) from d order by length(col) asc, col asc
或者。select id,col from d order by cast(trim('拆罩戚中文' from col) as signed)
根旅陵據實際悶殲情況看吧。
mysql 資料庫中 ,按照字母加數字的字串排序
4樓:典昊焱
select id, col,length(col) from d order by length(col) asc, col asc
或者select id,col from d order by cast(trim('中文' from col) as signed)
根據實際情況看吧。
5樓:蠻明朗鄺月
id為字串不好,建議可以多加乙個欄位作為id,用數值型別,而必須用字串的可以另加乙個欄位名。
sql語句中對乙個欄位排序,欄位中含有字串和數字,(怎根據數字進行排序)
6樓:網友
假如表為test,name欄位存放班級。
**如下:select id,name,substring_index(name, '班級',1) as num
from test
order by num asc
7樓:網友
order by 欄位名稱+0 desc/asc的形式進行排序。
order by 欄位名稱*1 desc/asc的形式進行排序。
mysql 字串數字排序
8樓:曾經有個怪叔叔
select a from t order by a
查詢時排序就上面這樣了。
還有你說,0-1-3-6-6 在上面? 那是因為 0-1-3-6-6 的長度比0-1-3-6-10-10 短所以排在上面?還是因為 6<10 所以排在上面啊?
急:mysql查詢結果字串的排序問題
9樓:訄訄很溫柔
你的「中文」是固定的文字嗎?12
下面的語句只支援9999以下的數字排序。
select id,col, right(col,length(col)-least(
if(locate('0',col) >0,locate('0',col),9999),if(locate('1',col) >0,locate('1',col),9999),if(locate('2',col) >0,locate('2',col),9999),if(locate('3',col) >0,locate('3',col),9999),if(locate('4',col) >0,locate('4',col),9999),if(locate('5',col) >0,locate('5',col),9999),if(locate('6',col) >0,locate('6',col),9999),if(locate('7',col) >0,locate('7',col),9999),if(locate('8',col) >0,locate('8',col),9999),if(locate('9',col) >0,locate('9',col),9999)
1) *1 a
from test4 order by a
sql語句問題:像這樣的字串欄位裡含有數字還有漢字的如何使他們按照數字順序排列
10樓:理工愛好者
把資料做一次清理。
提取資料裡你需要進行排序的資料放在乙個新欄位裡查詢時按提取的欄位進行排序即可。
注意資料型別哈。
mysql兩個數字型字串比較!詳細如下
11樓:網友
獲取當前時間也轉換成字串形式,然後分別擷取年,月,日,進行多重比較判斷可以了。。
12樓:
用between就可以比如:
select * from table where cast(a as signed) between cast(date1 as signed) and cast(date2 as signed);
你試試吧,好不好使。
MYSQL如何替換部分字串,在MYSQL中,如何批量替換字串中的某一個字元 如 123123 124124 125125 我需要將第一個字元1 替換成
如果是想查詢話 select substr 該欄位名,1,instr 該欄位名,1,2 1 from 表名 如果是想直接改變資料 update 表名 set 欄位名 substr 該欄位名,1,instr 該欄位名,1,2 1 語句是擷取第2個 之前的字串 如果想更長一些可以改變下面n的值為輸出到第...
Java問題 字串String,有字元 數字和特殊字元,怎樣從中提出字元判斷是否為數字或字元
考慮用貪婪正規表示式 從頭開始解析 0 9 abc xyz public class test930 執行結果 第一個 12,第二個 null,第三個 null,第四個 第一個 13,第二個 null,第三個 null,第四個 第一個 ax,第二個 a,第三個 x,第四個 第一個 by,第二個 b,...
求助 輸入字串,由小到大排序輸出
include include void px char p1 int main px str for i 0 i 5 i printf s n str i return 0 include include include void px char p1 5 int main px str for ...