 |
ผม join table แต่ไม่ต้องการแสดงค่าที่ซ้ำกันทำอย่างไรครับ |
|
 |
|
|
 |
 |
|
ผมมี 2 table นะครับ
table แรกชื่อ order มี id, first_name, last_name, address
table สองชื่อ order_detail มี id, order_id, product_name, option_name
ตัวอย่างข้อมูล
table order
0001, aaaa, bbbb, 12345 abcd
table order_detail
1, 0001, google, plus
2, 0001, twitter, eiei
ผมทำ join แล้วได้มาเป็น
Code
SELECT order.id, order.first_name, order.last_name, order.address, order_detail.product_name, order_detail.option_name FROM order JOIN order_detail ON (order.id=order_detail.order_id)
0001, aaaa, bbbb, 12345 abcd, google, plus
0001, aaaa, bbbb, 12345 abcd, twitter, eiei
ผมอยากให้แสดงผลโดยใช้ php เป็นแบบนี้ครับ
0001, aaaa, bbbb, 12345 abcd, google, plus
twitter, eiei
ผมไม่อยากได้พวกที่ซ้ำๆมา ต้องทำอย่างไรเหรอครับ ผมลอง while ดู มันก็แยกบรรทัดออกมาเป็น 2 record
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2015-06-14 00:54:40 |
By :
peam |
View :
683 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ผมเคยลอง group by product_name,option_name แล้วแต่ตรงตารางก็ไม่รวมกันอยู่ดีครับ
|
 |
 |
 |
 |
Date :
2015-06-14 01:32:54 |
By :
peam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|