 |
รบกวน ดู โค๊ด select ซ้อน select คือว่า รัน ไม่ออกเลย ครับ |
|
 |
|
|
 |
 |
|
รบกวน ผู้รู้ หน่อย ครับ
Code (PHP)
$spp1= mysql_query("SELECT count(order_generation) AS V_TOTAL1 , SUM(size_new) AS V_TOTAL , check_status , order_ID FROM genneration_size
WHERE check_status='0' or check_status='1' or check_status='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation");
while($spp1_row = mysql_fetch_array($spp1)){
$rs_menu = mysql_query("SELECT count(order_generation) AS V_TOTAL_new1 , SUM(size_new) AS V_TOTAL_new , check_status , order_ID FROM genneration_size
WHERE check_status!='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation");
$qu1=mysql_query($rs_menu);
while($arr1=mysql_fetch_array($qu1)){
$order_generation=$arr1['order_generation'];
$check_status=$arr1['check_status'];
$order_ID=$arr1['order_ID'];
$data[]= $arr1[V_TOTAL]."<br>";
$data[] = $arr1[V_TOTAL1]."<br>";
$data[]= $arr1[V_TOTAL_new]."<br>";
$data[] = $arr1[V_TOTAL_new1]."<br>";
$data_sum=$arr[V_TOTAL_new] * $arr1[V_TOTAL] ."<br>";
echo $data_sum."<br>";
}
}
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2013-03-18 17:00:01 |
By :
TonsoR |
View :
1131 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error อะไรครับ ?
|
 |
 |
 |
 |
Date :
2013-03-18 20:26:23 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$qu1=mysql_query($rs_menu) or die(mysql_error());
|
 |
 |
 |
 |
Date :
2013-03-19 08:54:44 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำให้เอา Query พวกนี้ไปทดสอบบน phpMyAdmin ให้มันผ่านก่อนครับ
Code (SQL)
SELECT count(order_generation) AS V_TOTAL1 , SUM(size_new) AS V_TOTAL , check_status , order_ID FROM genneration_size
WHERE check_status='0' or check_status='1' or check_status='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation
Code (SQL)
SELECT count(order_generation) AS V_TOTAL_new1 , SUM(size_new) AS V_TOTAL_new , check_status , order_ID FROM genneration_size
WHERE check_status!='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation
|
 |
 |
 |
 |
Date :
2013-03-19 09:16:07 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ออก แบบนี้ ครับ

Code (PHP)
SELECT count(order_generation) AS V_TOTAL1 , SUM(size_new) AS V_TOTAL , check_status , order_ID FROM genneration_size
WHERE check_status='0' or check_status='1' or check_status='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation

Code (PHP)
SELECT count(order_generation) AS V_TOTAL_new1 , SUM(size_new) AS V_TOTAL_new , check_status , order_ID FROM genneration_size
WHERE check_status!='2' AND order_generation IN ('ASD', 'CSD', 'HRG', 'LBG', 'LSD', 'OBD', 'PFR', 'RAL', 'WSG', '$hdata')
GROUP BY order_generation
ที่ผมทำไม่ได้ ตอนนี้ คือ เอา V_TOTAL1 / V_TOTAL = ผลลัพธ์ แล้ว ก็เอาผลลับ คูณ V_TOTAL_new
|
ประวัติการแก้ไข 2013-03-19 13:58:22 2013-03-19 14:01:16
 |
 |
 |
 |
Date :
2013-03-19 10:51:30 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้พอมีวิธีไหน ที่ทำให้ เชื่อมกันได้หรือ เปล่า ครับ เพราะผมเอาไปรันใน phpMyAdmin รันออก ครับ
V_TOTAL1 / V_TOTAL = ผลลัพธ์ แล้ว ก็เอาผลลับ คูณ V_TOTAL_new
|
 |
 |
 |
 |
Date :
2013-03-21 08:48:47 |
By :
TonsoR |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|