zoukankan      html  css  js  c++  java
  • 查询知识点详情

    SELECT bqk.id,bqk.cn_name as cnName,bqk.recorder,bqk.record_time as recordTime
         ,GROUP_CONCAT(rel_tab.textbooks_id) as relateTextbookString
         ,GROUP_CONCAT(rel_tab.address) as address
         ,TRIM(TRAILING '|' FROM GROUP_CONCAT(rel_tab.textbooks_page,'|'))  as relatePageString
         ,TRIM(TRAILING '|' FROM GROUP_CONCAT(rel_tab.textbooks_page_name,'|'))  as relatePageNameString
         ,TRIM(TRAILING '|' FROM GROUP_CONCAT(rel_tab.kp_mistakes_id,'|'))  as relateMistakesIdString
    FROM question_knowledge bqk
        LEFT JOIN (
            SELECT * FROM
            (
                  SELECT dis_page_tab.id,dis_base_tk.textbooks_id,dtxt.address,group_concat(dis_base_tk.textbooks_page) as textbooks_page,group_concat(dis_base_tk.textbooks_page_name) as textbooks_page_name,group_concat(dis_base_tk.kp_mistakes_id) as kp_mistakes_id
                  FROM (
                      SELECT dis_qk.id, dis_tk.textbooks_page as relatePageString
                      FROM question_knowledge dis_qk,
                           textbooks_knowledge dis_tk
                      WHERE dis_tk.qknowledge_id = dis_qk.id
                        AND dis_qk.id = 1168
                      GROUP BY dis_tk.textbooks_page
                      HAVING COUNT(dis_tk.textbooks_page) = 1
                  ) dis_page_tab
                     ,textbooks_knowledge dis_base_tk
                          LEFT JOIN textbooks dtxt ON dis_base_tk.textbooks_id = dtxt.id
                  WHERE dis_page_tab.id = dis_base_tk.qknowledge_id
                    AND dis_page_tab.relatePageString = dis_base_tk.textbooks_page
                  GROUP BY dis_base_tk.textbooks_id
                  ) tb1
                UNION ALL (
                    SELECT same_page_tab.id,same_base_tk.textbooks_id,stxt.address,same_base_tk.textbooks_page as textbooks_page_name,same_base_tk.textbooks_page_name as textbooks_page_name,same_base_tk.kp_mistakes_id as kp_mistakes_id
                    FROM (
                        SELECT dis_qk.id, dis_tk.textbooks_page as relatePageString
                        FROM question_knowledge dis_qk,
                             textbooks_knowledge dis_tk
                        WHERE dis_tk.qknowledge_id = dis_qk.id
                          AND dis_qk.id = 1168
                        GROUP BY dis_tk.textbooks_page
                        HAVING COUNT(dis_tk.textbooks_page) > 1
                    ) same_page_tab
                       ,textbooks_knowledge same_base_tk
                            LEFT JOIN textbooks stxt ON same_base_tk.textbooks_id = stxt.id
                    WHERE same_page_tab.id = same_base_tk.qknowledge_id
                      AND same_page_tab.relatePageString = same_base_tk.textbooks_page
                )
            ) rel_tab
        ON bqk.id = rel_tab.id
    WHERE bqk.state=1 AND bqk.id=1168
    GROUP BY bqk.id
    ;
    
  • 相关阅读:
    「模拟赛20180306」回忆树 memory LCA+KMP+AC自动机+树状数组
    python写一个通讯录
    Git学习笔记
    交换排序
    用Windows自带的方法创建WiFi
    MySQL之触发器
    插入排序
    range和arange的区别
    Spring前后端跨域请求设置
    三、图的定义及遍历
  • 原文地址:https://www.cnblogs.com/tangyouwei/p/10484616.html
Copyright © 2011-2022 走看看