我想從電話列中選擇拆分記錄。
我的桌子看起來像這樣:
customerId phone address ...
1 1234567 qwe ...
2 234567,135791,4556457 asd ...
3 3425546,34454365 zxc ...
我需要使用 customerId 分別選擇每個電話號碼:
1 1234567
2 234567
2 135791
2 4556457
3 3425546
3 34454365
我不想更改表并拆分到不同的行,只想選擇。
謝謝!
uj5u.com熱心網友回復:
使用string_split()與演唱會CROSS APPLY...使用OUTER APPLY,如果你想看到NULL值
Select A.customerID
,Phone = B.value
From YourTable A
Cross Apply string_split(A.Phone,',') B
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/311522.html
標籤:sql sql-server 查询语句
上一篇:SQL-LEAD和LAG查詢
