本文介紹了Mysql 可以拆分列嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我有一列包含逗號分隔的數(shù)據(jù):
I have a column that has comma separated data:
1,2,3
3,2,1
4,5,6
5,5,5
我正在嘗試運行將分別查詢 CSV 字符串的每個值的搜索.
I'm trying to run a search that would query each value of the CSV string individually.
0<first<5 and 1<second<3 and 2<third<4
我知道我可以返回所有查詢并自己拆分并自己比較.我很好奇是否有辦法做到這一點,以便 mysql 進行處理工作.謝謝!
I get that I could return all queries and split it myself and compare it myself. I'm curious if there is a way to do this so mysql does that processing work. Thanks!
推薦答案
使用
substring_index(`column`,',',1) ==> first value
substring_index(substring_index(`column`,',',-2),',',1)=> second value
substring_index(substring_index(`column`,',',-1),',',1)=> third value
在你的 where 子句中.
in your where clause.
SELECT * FROM `table`
WHERE
substring_index(`column`,',',1)<0
AND
substring_index(`column`,',',1)>5
這篇關(guān)于Mysql 可以拆分列嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!