我发现很难确定什么是从由 where 语句过滤的表中计算某些特定记录的最快方法是我的代码,以下是查询:
$type_mo3ln_malk = mysql_num_rows(mysql_query("SELECT * FROM `tableshow` $weress AND mo3ln_type='malk'"));
$type_mo3ln_mswg = mysql_num_rows(mysql_query("SELECT * FROM `tableshow` $weress AND mo3ln_type='mswg'"));
$type_mo3ln_mktb = mysql_num_rows(mysql_query("SELECT * FROM `tableshow` $weress AND mo3ln_type='mktb'"));
$type_mo3ln_wkeel = mysql_num_rows(mysql_query("SELECT * FROM `tableshow` $weress AND mo3ln_type='wkeel'"));
$type_mo3ln_no = mysql_num_rows(mysql_query("SELECT * FROM `tableshow` $weress AND mo3ln_type='0'"));
进行计数的函数是在 php 中预定义的函数
我正在考虑使用 count() 函数,但我想知道是否可以将 Sum 函数仅用于某些特定行,正如 Mr.Hates 在此处建议的那样 Get record counts for all tables in MySQL database