我有四個表僱員,association_employees,協會,association_items。 下面的select查詢爲我提供了連接的行。通過將列填充到列表中來組合多行。
注意:我已經爲SQL和Coldfusion語言製作了標籤,這是因爲我正在使用coldfusion作爲我的腳本語言。我不確定我是否應該依賴SQL或使用我的腳本語言。
查詢
SELECT AE.userid, E.firstname,
A.title, AI.itemvalue
FROM associations_employees AE INNER JOIN
employees E on E.userid = AE.useridFK INNER JOIN
associations A on A.associationid = AE.associationidFK INNER JOIN
association_items AI on AI.associationidFK = AE.associationidFK
當前選擇輸出
userID firstname title itemvalue
------ --------- ----- ---------
5603 Jesh Learner Type Family Literacy
5603 Jesh Learner Type Elementary School
5603 Jesh Learner Type Academic
5603 Jesh Personnel Type Staff
5605 jennone Personnel Type Site Supervisor
5605 jennone Personnel Type Rops member
5607 Sharon Personnel Type Rops member
5607 Sharon Personnel Type Site Supervisor
5607 Sharon Mentor Type High School
5607 Sharon Mentor Type Op. Read
5607 Sharon Mentor Type Enrichment
5607 Sharon Mentor Type General
正如可以注意到,存在從 '項目值' 列開類似的多個行。 我需要結合這些行來產生以下結果。
最少報名輸出
userID firstname title itemvalue
------ --------- ------ ---------
5603 Jesh Learner Type Family Literacy;Elementary School;Academic
5603 Jesh Personnel Type Staff
5605 jennone Personnel Type Rops member;Site Supervisor;Staff
5607 Sharon Personnel Type Rops member;Site Supervisor
5607 Sharon Mentor Type Enrichment;General;High School;Op. Read
那麼,爲什麼倒票? – RRK