 |
ช่วยดู CODE นี้ให้ผมด้วยนะครับ จาก code ใช้งานได้ปกตินะครับ แต่ ผมต้องการที่จะให้มันเลือกเอา TOTAL ที่รวมกันแล้วได้มากกว่า 2 |
|
 |
|
|
 |
 |
|
Code
SELECT COUNT(l_cause )AS TOTAL , student_tk.s_id , student_tk.s_name , student_tk.s_class , student_tk.s_room , learning.l_day , learning.l_month , learning.l_year , learning.l_hour , learning.l_course , learning.s_id , learning.l_cause FROM student_tk INNER JOIN learning ON student_tk.s_id =learning.s_id WHERE student_tk.s_id GROUP BY student_tk.s_id , learning.l_cause ORDER BY `TOTAL` DESC
จาก code ใช้งานได้ปกตินะครับ แต่ ผมต้องการที่จะให้มันเลือกเอา TOTAL ที่รวมกันแล้วได้มากกว่า 2 หนะครับ ไม่ทราบว่าต้องทำยังไง เพราะ TOTAL มันไม่ได้อยู่ใน ฐานข้อมูลครับ
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2011-09-14 17:40:35 |
By :
tk |
View :
756 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code
SELECT @TOTAL=COUNT(l_cause) , student_tk.s_id , student_tk.s_name , student_tk.s_class , student_tk.s_room , learning.l_day , learning.l_month , learning.l_year , learning.l_hour , learning.l_course , learning.s_id , learning.l_cause FROM student_tk INNER JOIN learning ON student_tk.s_id =learning.s_id WHERE student_tk.s_id AND @TOTAL>2 GROUP BY student_tk.s_id , learning.l_cause ORDER BY `TOTAL` DESC
อย่างนี้ได้หรือเปล่าครับ แต่ผมไม่แน่ใจนะครับ
|
 |
 |
 |
 |
Date :
2011-09-15 11:52:55 |
By :
ongsa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ครับ
|
 |
 |
 |
 |
Date :
2011-09-15 14:22:41 |
By :
tk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองตัด ตรง ORDER BY ทิ้งครับ
|
 |
 |
 |
 |
Date :
2011-09-15 15:53:49 |
By :
ongsa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วครับ ไม่ได้เหมือนเดิม มันบอกว่าไม่พบข้อมูลเลย ทั้งๆที่มีข้อมูลที่มากกว่าอยู่ครับ
|
 |
 |
 |
 |
Date :
2011-09-15 20:09:21 |
By :
tk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|