Can you split/explode a field in a MySQL query?

后端 未结 17 1090
无人及你
无人及你 2020-11-22 04:03

I have to create a report on some student completions. The students each belong to one client. Here are the tables (simplified for this question).

CREATE TAB         


        
17条回答
  •  长发绾君心
    2020-11-22 04:42

    SELECT
      tab1.std_name, tab1.stdCode, tab1.payment,
      SUBSTRING_INDEX(tab1.payment, '|', 1) as rupees,
      SUBSTRING(tab1.payment, LENGTH(SUBSTRING_INDEX(tab1.payment, '|', 1)) + 2,LENGTH(SUBSTRING_INDEX(tab1.payment, '|', 2))) as date
    FROM (
      SELECT DISTINCT
        si.std_name, hfc.stdCode,
        if(isnull(hfc.payDate), concat(hfc.coutionMoneyIn,'|', year(hfc.startDtae), '-',  monthname(hfc.startDtae)), concat(hfc.payMoney, '|', monthname(hfc.payDate), '-', year(hfc.payDate))) AS payment
      FROM hostelfeescollection hfc
      INNER JOIN hostelfeecollectmode hfm ON hfc.tranId = hfm.tranId
      INNER JOIN student_info_1 si ON si.std_code = hfc.stdCode
      WHERE hfc.tranId = 'TRAN-AZZZY69454'
    ) AS tab1
    

提交回复
热议问题