我想重新格式化MySql表格以便在網絡節點映射程序中使用。原來的格式是:MySql查詢獲取相同表格字段中所有元素的組合
| ID | story | org | scribe |
,我想所有組織名稱拉進兩個輸出表是這樣的:
| org1 | org2 | scribe | weight of connection |
ORG1原始表ORG2都來自同一個領域,通過共享一個或多個抄寫員而彼此相關。所有抄寫員都有唯一的ID。當然,我不想重複輸入。
我CAN做到目前爲止是把所有由做一個「%文本%」爲組織搜索,然後排除組織從輸出連接到任何一個組織在列表中,像這樣的機構單位:
SELECT 'tabitha' as org1,
org as org2,
teller as scribe_id,
count(teller) as weight
FROM `stories`
WHERE teller in
(
(SELECT
teller
FROM `stories`
WHERE org like '%tabitha%'
group by teller)
)
and org not like '%tabitha%'
group by teller, org
所以我覺得有關於自連接或當可能的工作情況下,一些伎倆,但我還沒有發現任何東西。
感謝您的答案,工作,稍微調整一下。 – 2010-12-09 21:12:29