亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在相同條件下從 2 表中獲取值

如何在相同條件下從 2 表中獲取值

PHP
九州編程 2021-06-15 13:41:57
我有 2 個表,t_silm 和 t_revenue,我想用相同的條件將兩個表相加。這是我的表示例:https://ibb.co/JtCp80wt_silmbl - th - tw - total10 - 2018 - 4 - 10011 - 2018 - 4 - 20012 - 2018 - 4 - 300t_revenuebl - th - tw - jumlah10 - 2018 - 4 - 2511 - 2018 - 4 - 7012 - 2018 - 4 - 45我想得到結果:avg = total / jumlah;condition =  tw =4 and th = 2018;請有人可以幫助我嗎?$query = "SELECT sum(t_slim.pemakaian_309) as to1, sum(t_revenue.jumlah) as to2, to1/to2 as taverage             from t_slim t1 INNER JOIN t_revenue t2 on t1.tahun=t2.tahun             and t1.triwulan=t2.triwulan WHERE t1.tahun=$tahun and t1.triwulan=$triwulan GROUP BY bulan";    $hasil = mysql_query($query);  $baris = 3;   while ($data = mysql_fetch_array($hasil))  {  $worksheet2->write_string(11, $baris, number_format($data['taverage'],2),$format2);  $baris++;    }
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 145 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號