原生mysqli_query和mysql批量更新,分類查詢

$result_array= mysqli_query($conn, "select gmbh,skbh from xiaozu_zngz limit ".$newhead.",".$num);
while ($row = mysqli_fetch_array($result_array)) {
        echo $row['gmbh'] . "-" . $row['skbh'];
    }

批量更新

update xiaozu_order set
	orderdistype = CASE order_shopfadan_cost
		WHEN 1.5 THEN 'jin'
		WHEN 2 THEN 'zhong'
		WHEN 2.5 THEN 'yuan'
	END
where addtime > 1588262400 and status = 3

分類查詢

select orderdistype,count(case when orderdistype='jin' then 1 end) as jin,
count(case when orderdistype='zhong' then 1 end) as zhong,
count(case when orderdistype='yuan' then 1 end) as yuan
from  xiaozu_order where addtime > 1588262400 and status = 3
group by orderdistype
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章