|
 |
|
พี่ๆครับ ช่วยหน่อยครับ อยากถามเรื่อง การ join table ครับผม |
|
 |
|
|
 |
 |
|
ใช้ INNER JOIN คับ
Code (PHP)
แบบที่1 : ANSI SQL-92 Syntax
select emp_name, employee_info.emp_id, proj_id, hours
from employee_info INNER JOIN proj_hours
on employee_info.emp_id = proj_hours.emp_id
แบบที่2 : Transact-SQL
select emp_name, employee_info.emp_id, proj_id, hours
from employee_info, proj_hours
where employee_info.emp_id = proj_horus.emp_id
INNER JOIN แบบหลายเงื่อนไข
แบบที่1
select emp_employee, employee.emp_id, proj_id, hours
from employee_info INNER JOIN proj_hours
on employee_info.emp_id = proj_hours.emp_id
where emp_name = 'ชื่อฟิวล์'
แบบที่2
select emp_name, employee_info.emp_id, proj_id, hours
from employee_info, proj_hours
where employee_info.emp_id = proj_hours.emp_id
and emp_name = 'ชื่อฟิวล์'
หลักๆของ INNER JOIN ก้อไปมาณนี้ สิ่งที่ควรระวังในการเขียนคำสั่ง join ก็คือจะมีการอ้างชื่อคอลัมน์จากหลายเทเบิล และบางครั้งเทเบิลเหล่านั้นก็อาจจะมีชื่อคอลัมน์ซ้ำกันก้อได้ เวลาอ้างถึงชื่อคอลัมน์ที่ซ้ำกันต้องระบุชื่อเทเบิลนำหน้าทุกครั้ง
ผมความรู้น้อย ยังไงก้อรอผู้รู้มาตอบต่อระกันคับ
|
 |
 |
 |
 |
Date :
2010-12-28 15:09:31 |
By :
cmdping |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|