|
 |
|
สอบถามการ เลือกข้อมูลจาก database มาโชว์ คร่าา ในดาต้าเบส ได้เก็บค่าเป็น รหัสไว้ แต่ต้องการแสดงค่าออกเป็นชื่อ ต้องเอาตารางมา join กันหรือป่าวคะ |
|
 |
|
|
 |
 |
|
Join กัน 2 ตารางครับ
$strSQL"SELECT B.name,B.surename FROM table_ID A LEFT JOIN table_name B ON(A.id=B.id) WHERE id='ค่ารหัสที่ต้องการ' ";
|
 |
 |
 |
 |
Date :
2009-09-29 09:07:06 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไข (เพิ่ม = ) 
$strSQL="SELECT B.name,B.surename FROM table_ID A LEFT JOIN table_name B ON(A.id=B.id) WHERE id='ค่ารหัสที่ต้องการ' ";
|
 |
 |
 |
 |
Date :
2009-09-29 09:08:00 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งงอ่าค่ะ
จะเลือกชื่อ จากตาราง faculty มาแสดงแทน รหัสคณะอ่ะค่ะ
ขอบคุนคร่า
|
 |
 |
 |
 |
Date :
2009-09-29 09:50:21 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

ตามรูปอ่ค่ะ
|
 |
 |
 |
 |
Date :
2009-09-29 09:59:04 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ WOW WOW มีกี่ตารางครับ ?
คือจะให้แสดงชื่อคณะอย่างเดียวใช่เปล่าครับ
อย่างนี้เปล่า ไม่รู้ตรงคำถามเปล่านะ ตอนแรกคิดว่ามี 2 ตาราง
SELECT ชื่อคณะ FROM ตารางคณะ WHERE ฟิวดิ์รหัส='รหัสที่ต้องการให้แสดง'
|
 |
 |
 |
 |
Date :
2009-09-29 10:02:03 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ของนุ้ย มี2ตารางอ่ะค่ะ
คือ faculty (ID_Fac,Nm_Fac)
department (ID_Fac,ID_Dep,Dep_Name)
ค่ะ
โดยจากรูปข้างบนเลือกจากตาราง department อ่ะค่ะ
แล้วตรงที่เป็นรหัสน่ะค่ะ อยากให้แสดงชื่อที่อยู่ในตาราง faculty ค่ะ
ขอบคุน คุณonizike มากคร่า
|
 |
 |
 |
 |
Date :
2009-09-29 10:10:07 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$strSQL="SELECT A.Dep_Nmae,B.Nm_Fac FROM department A LEFT JOIN faculty B ON(A.ID_Fac=B.ID_Fac)";
|
 |
 |
 |
 |
Date :
2009-09-29 10:50:38 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ขึ้นเลยอ่ะค่ะ ทามงายดี
|
 |
 |
 |
 |
Date :
2009-09-29 11:13:15 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษที่ครับ เขียนผิด เป็น A.Dep_Name 
SELECT A.Dep_Name,B.Nm_Fac FROM department A LEFT JOIN faculty B ON(A.ID_Fac=B.ID_Fac)
|
 |
 |
 |
 |
Date :
2009-09-29 11:30:50 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งงอยุ่ตั้งนาน ที่แท้ ลืมเปลี่ยนค่าที่จะรับนั่นเอง อิอิ
ขอบคุนน๊าคะ
|
 |
 |
 |
 |
Date :
2009-09-29 15:58:02 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|