Just algorithm!
Sql - Command สำหรับ Select แบบ Join String

ไปอ่านเจอมาจาก ที่นี่ ครับ
คือว่า Oracle จะมี Command wm_concat ไว้สำหรับ Join string
แต่ Sql ดันไม่มีคำสั่งนี้ ซะนี่

วิธีแก้ไขคือใช้คำสั่ง FOR XML ครับ
สมมติว่า ต้องการ join Col1 จากตาราง Table1 ด้วย comma
เขียนอย่างนี้ครับ

SELECT
    (SELECT Col1 + ', '
     FROM Table1
     FOR xml path('')) AS csv




Create Date : 28 พฤษภาคม 2553
Last Update : 10 พฤศจิกายน 2557 21:03:14 น. 1 comments
Counter : 471 Pageviews.

 


โดย: หาแฟนตัวเป็นเกลียว วันที่: 28 พฤษภาคม 2553 เวลา:15:43:46 น.  

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 

chaowman
Location :
กรุงเทพฯ Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 8 คน [?]





New Comments
Group Blog
 
All Blogs
 
Friends' blogs
[Add chaowman's blog to your web]
Links
 

 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.