第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

MySQL - 如何修改父/子選擇查詢以將更多子項添加到現(xiàn)有數(shù)組/JSON?

MySQL - 如何修改父/子選擇查詢以將更多子項添加到現(xiàn)有數(shù)組/JSON?

PHP
BIG陽 2021-06-17 15:13:01
我有以下查詢工作正常:SELECT core_condition AS name, NULL AS parentFROM condition_theme_lookupUNION ALLSELECT theme_name AS name, condition_theme_lookup.core_condition AS parentFROM theme, condition_theme_lookupUNION ALLSELECT strand.strand_name AS name, theme.theme_name AS parentFROM strandJOIN theme ON theme.theme_pk = strand.theme_fk結(jié)果數(shù)組,使用一些 PHP,生成以下 JSON,到目前為止還不錯,顯示了“主題”父母的“鏈”子代:{    "name": "Condition",    "children": [{        "name": "Professional",        "children": [{            "name": "Professional Behavours"        }, {            "name": "Self-Care and Self-Awareness"        }, {            "name": "Medical Ethics and Law"        }]    }, {        "name": "Leader",        "children": [{            "name": "Teamwork and Leadership"        }, {            "name": "Collaborative Practice"        }, {            "name": "Health Systems and Careers"        }]    }, {        "name": "Advocate",        "children": [{            "name": "Health Advocacy"        }, {            "name": "Aboriginal Health"        }, {            "name": "Diversity and Inequality"        }, {            "name": "Health Promotion"        }]    }, {        "name": "Clinician",        "children": [{            "name": "Scientific Knowledge"        }, {            "name": "Patient Assessment and Clinical Reasoning"        }, {            "name": "Patient Management"        }, {            "name": "Patient Perspective"        }, {            "name": "Clinical Communication"        }, {            "name": "Quality Care"        }]    }, {        "name": "Educator",        "children": [{            "name": "Life-Long Learning"        }, {            "name": "Mentoring Relationships"        }, {            "name": "Patient Education"        }, {            "name": "Teaching and Learning"        }, {            "name": "Assessment and Evaluation"        }]    },我現(xiàn)在想添加相同的孩子集:'Year 1'、'Year 2'、'Year 3' 和'Year 4',從 tablestrand.year到每個strand.strand_name父母(例如職業(yè)行為、醫(yī)學(xué)倫理和法律等)。
查看完整描述

3 回答

?
POPMUISE

TA貢獻1765條經(jīng)驗 獲得超5個贊

當(dāng)您嘗試向原始查詢添加額外部分時 - 這應(yīng)該在“JOIN”部分之后完成,而不是在它之前完成?!癑OIN”屬于上一個查詢。這個版本應(yīng)該可以工作:


SELECT core_condition AS name, NULL AS parent

FROM condition_theme_lookup

UNION ALL

SELECT theme_name AS name, condition_theme_lookup.core_condition AS parent

FROM theme, condition_theme_lookup

UNION ALL

SELECT strand.strand_name AS name, theme.theme_name AS parent

FROM strand

JOIN theme ON theme.theme_pk = strand.theme_fk

-- beginning of added query --

UNION ALL

SELECT strand.year AS name, strand.strand_name AS parent

FROM strand WHERE strand.year is not NULL;

我還添加了條件“WHERE strand.year is not NULL” - 如果您確定所有記錄都設(shè)置了年份,請?zhí)^這一部分。


查看完整回答
反對 回復(fù) 2021-06-19
  • 3 回答
  • 0 關(guān)注
  • 157 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號