 |
ต้องการจะ join ตารางที่ให้มา join แล้วไม่แสดงอารัยเลย |
|
 |
|
|
 |
 |
|

รบกวนเขียนให้ดูหน่อยนะคะ
ซึ่งดึงข้อมูลจากตาราง cpu มาแสดงแต่งต้องการให้แสดงเป็นรายชื่อโดยการ joinตาราง ตัวอย่างที่join
$query ="select ID_Code,name_Department,type_machine,machine_name,Printer_name,Equipment_name,Date,sticker,IPAddress,Network from cpu,department,machine,printer,equipment INNER JOIN cpu.Code_Department = department.Code_Department,cpu.machine_code = machine.machine_code,cpu.Printer_code = printer.Printer_code,cpu.Equipment_code = equipment.Equipment_code order by ID_Code";
ช่วยแก้ให้ด้วยนะคะ
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2010-10-04 15:24:48 |
By :
janjira0019 |
View :
1012 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดู วิธีการใช้ก่อนไหม https://www.thaicreate.com/tutorial/sql-join.html
อืมน่าจะลอง join ที่ละตารางนะจะได้รู้ว่าผิดตรงไหน?????ค่ะ
|
 |
 |
 |
 |
Date :
2010-10-04 15:30:43 |
By :
penpimonmink |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุนคะ 
|
 |
 |
 |
 |
Date :
2010-10-05 09:50:31 |
By :
janjira0019 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$sql = "
SELECT
cpu.ID_Code,
dep.name_Department;
cpu.type_machine,
mac.machine_name,
prt.Printer_name,
equ.Equipment_name,
cpu.Date,
cpu.sticker,
cpu.IPAddress,
cpu.Network
FROM cpu JOIN department dep ON cpu.Code_Department = dep.Code_Department
JOIN machine mac ON cpu.machine_code = mac.machine_code
JOIN printer prt ON cpu.Printer_code = prt.Printer_code
JOIN equipment equ ON cpu.Equipment_code = equ.Equipment_code
ORDER BY cpu.ID_Code";
น่าจะประมาณนี้ครับ
เอาคำสั่งไปรันใน phpmyadmin ดูก่อน นะครับ หรือไม่ก็โหลดพวก GUI เขียน SQL ก่อนรันให้ได้ผลลัพธ์แล้วค่อยเอาไปรวมกับ php
ตัวที่ผม แนะนำคือ HeidiSQL ครับ
ปล. column Date ในตาราง cpu ไม่ควรตั้งชื่อนี้ครับ เพราะว่าคำว่า Date น่าจะเป็นคำสงวนนะครับ
|
 |
 |
 |
 |
Date :
2010-10-05 10:22:46 |
By :
DS_Ohm |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|