BMS-HOSxP Community
HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: gweeped ที่ กุมภาพันธ์ 08, 2012, 10:41:20 AM
-
คือดึงข้อมูล จากตาราง patient โดนใช้ Select patient.*
แล้วจะแสดง ข้อมูลเชื้อชาติหน้าฟอร์ม ต้องใช้คำสั่งยังไงคะ
เช่น nationality ค่าเป็น 99 แล้วจะให้แสดงเป็น ไทย
ใช้แบบนี้โดยแทน variable ก็ไม่ออก
Value := GetSQLStringData('SELECT nationality.name' +
'FROM nationality INNER JOIN'+
'patient ON patient.nationality = nationality.nationality');
-
นั่งเรีนบเรียงคำถามใหม่ได้ความว่า
อยากดึงค่าจาก nationality ใน patient แล้วไปเชื่อมกับ ค่า nameในตาราง nationality ค่า
โดยตอนนี้คำสั่ง หลักๆได้ดังนี้
select pt.*
from patient pt
where hn = xxxxxxx
-
ลองดูนะครับ
select pt.hn,concat(pt.pname,pt.fname," ",pt.lname)as ptname,n.name as nation_name
from patient pt
left outer join nationality n on n.nationality=pt.nationality
where pt.hn=xxxxxxx
หรือสร้าง variable มา 1 ตัว
value := GetSQLStringData(' select n.name as nationallity_name from patient pt '+
' left outer join nationality n on n.nationality=pt.nationality '+
' where pt.hn=DBPipeline['hn'] ');
-
ถ้าอยากได้ citizenship ก็ต้องแปลงเป็นแบบนี้ใช่มั้ยคะ
value := GetSQLStringData(' select n.name as nationallity_name from patient pt '+
' left outer join nationality n on n.nationality=pt.citizenship '+
' where pt.hn=DBPipeline['hn'] ');
อีกตัวขอ country ด้วยคะ ไม่ทราบว่าต้องไปเชื่อมกับ table ไหนคะ หาไม่เจอ ??? ???
-
thaiaddress