mysql取出括号内的内容

    技术2022-07-17  67

    有一个表(consult )中,有字段type为(2-15)(1-6)(2-11)(1-1)(1-3)(1-2)(2-12)(2-16)(0-2)(1-4)(2-14)(1-10)(2-17)(2-13)(1-7)(0-1)(1-5)

    select substring_index(substring_index(type,")",i.id),'(',-1) as t from consult c,ids i  where i.id < (select length(type)-length(replace(type,')','')) + 1)

     

    其中ids表为一个只有自增id的表,用于辅助查询

    Processed: 0.015, SQL: 9