我想在mySQL中進行查詢,如果department_name包含在「departments_handling_the_process」中,需要使用process_table的「process_name」的連接內容更新department_table的「processes_handled」領域。MYSQL查詢使用CONTAINS更新字段
這是我的問題是什麼樣子:
department_table
department_name | processes_handled
Department 1 | Process A; Process B; Process D;
Department 2 | Process A; Process C: Process E; Process G;
Department 3 | Process C; Process D; Process F
process_table
process_name | departments_handling_the_process
Process A | Department 1; Department 2
Process B | Department 1
Process C | Department 2; Department 3
Process D | Department 1; Department 3
Process E | Department 2
Process F | Department 3
Process G | Department 2
我現在的更新語句如下:
UPDATE department_table,process_table
SET processes_handled= (SELECT GROUP_CONCAT(`process_name SEPARATOR '; ')
FROM process_table
WHERE CONTAINS(process_table.departments_handling_the_process, department_table.department_name))
WHERE CONTAINS(process_table.departments_handling_the_process, department_table.department_name)
;
我希望你能幫助我解決我的發言。感謝和更多的權力!
帶電作業請閱讀本功能:http://stackoverflow.com/a/3653574/447489 – fancyPants
謝謝你的迴應!不過,我在數據庫列中的分隔列表中沒有問題。 – Rezard
還沒...相信我。 – fancyPants