我想从AssignedTo
中的JSON数组Table_1
中提取ID
使用该数据从Table_2
中提取
然后将AssignedTo
中Table_1
中的数据替换为Table_2
Table_1
JobID Table_2_ID
101 [403, 404, 405]
102 [406, 407, 408]
103 [409, 410, 411]
Table_2
personID FirstName LastName
403 Josh Adams
404 Mary Poppins
405 Mickey Mouse
406 Donald Duck
407 Pete Schmit
408 Anna Bagel
409 Jake Crabs
410 Sponge Bob
411 Stuart Little
SELECT JobID, AssignedTo (REPLACE AssignedTo[0-2] WITH
CONCAT(Table_2.FirstName, ' ', Table_2.LastName
WHERE Table_1.AssignedTo = Table_2.personID)
FROM Table_1, Table_2
结果:
JobID AssignedTo
101 [Josh Adams, Mary Poppins, Micky Mouse]
102 [Donald Duck, Pete Schmit, Anna Bagel]
103 [Jake Crabs, Sponge Bob, Stuart Little]