mysql 截取字符串
建库:CREATE TABLE temp123 (val varchar(100));
插数据:INSERT INTO temp123 VALUES ('123||http://localhost:9999/Upload/Images/ask/2011/7/29/129564046197968750.jpg||456');
截取字符串 :SELECT CONCAT( SUBSTRING_INDEX(val, '||', 1),SUBSTRING_INDEX(val, '||', -1)) AS RESULT FROM temp123;
结果:返回123456
-----------------------------------------
选择所有maistatus用,隔开,最后为 4 的所有数据。
SELECT * FROM Main m where SUBSTRING_INDEX(maistatus, ',', -1) = 4 order by mid desc