 |
เกี่ยวกับการดึงข้อมูลของตารางที่ความสัมพันธ์กันครับ ช่วยหน่อยครับ |
|
 |
|
|
 |
 |
|
select a.student, a.name, b.status_name from data_student a
inner join status b on a.status_code = b.status_code
ลองดูครับว่าใช่ที่ต้องการหรือเปล่า
|
 |
 |
 |
 |
Date :
2009-05-06 13:47:00 |
By :
windersun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ครับ
|
 |
 |
 |
 |
Date :
2009-05-06 13:56:02 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอความช่วยเหลืออยู่นะครับ
|
 |
 |
 |
 |
Date :
2009-05-06 14:03:00 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้จากคุณ windersun
select a.student_code, a.name, b.status_name from data_student a
inner join status b on a.status_code = b.status_code
|
 |
 |
 |
 |
Date :
2009-05-06 14:08:29 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอถามด้วยความไม่เข้าใจครับ
a.student_code b.statust ตรง a. b.นี่มันหมายถึงอะไรเหรอครับ
|
 |
 |
 |
 |
Date :
2009-05-06 14:19:02 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
a, b เป็นการตั้งชื่อตารางขึ้นมาใหม่ คล้ายๆกับการตัวตัวแปรของ php อะครับ
คือให้ a คือ ตาราง data_student และ b คือตาราง status
|
 |
 |
 |
 |
Date :
2009-05-06 14:23:37 |
By :
windersun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
data_student a
status b
เปลี่ยนชื่อเรียกให้มันสั้นๆ จะได้เขียนง่ายขึ้น(หรือเปล่า) ถ้าจะให้มันเต็มๆ ก็ต้อง
data_student.student_code
status.statust
|
 |
 |
 |
 |
Date :
2009-05-06 14:24:10 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเขียนแบบนี้ มันไม่ได้ อะครับ มั่ว ๆ เอา
$tb="SELECT data_student.stdent_code.student_name,status.status_name from data_student inner join status on status_code = status_code WHERE student_code='$valid _user' ";
|
 |
 |
 |
 |
Date :
2009-05-06 14:36:32 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$tb="SELECT data_student.stdent_code.student_name,status.status_name from data_student inner join status on data_student.status_code = status.status_code WHERE data_student.student_code='$valid _user' ";
|
 |
 |
 |
 |
Date :
2009-05-06 14:40:17 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้อะครับ
|
 |
 |
 |
 |
Date :
2009-05-06 15:12:16 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยบอก error ด้วยครับ บอกแค่ไม่ได้นี่ผมก็มึนเหมือนกันครับ
|
 |
 |
 |
 |
Date :
2009-05-06 15:34:16 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มัน error แบบนี้ครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
|
 |
 |
 |
 |
Date :
2009-05-06 15:35:30 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รออยู่นะคร๊าบ
|
 |
 |
 |
 |
Date :
2009-05-06 16:18:07 |
By :
taknaja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$tb="SELECT data_student.stdent_code, data_student.student_name,status.status_name from data_student, status_code WHERE data_student.student_code='$valid _user' and student.studen.code = status.status.code;
คือลอง ง่าย ๆ ก่อนนะ แต่งง file คุณ ลองดูนะ...
|
 |
 |
 |
 |
Date :
2009-05-11 08:25:16 |
By :
Backer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|