我有一个联合类型查询。如何计算查询的行数?
mysql_query(
" (SELECT 1 as sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL $performeridSql)
UNION
(SELECT 2 as sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL
$categorySql $buildSql
$breastsize $haircolor $age $ethnicity
$willingnessSql)
ORDER BY sort_col");
最佳答案
只需计算子查询结果...
SELECT COUNT(t.*) FROM
( (SELECT 1 AS sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL
$performeridSql)
UNION
(SELECT 2 AS sort_col,performerid,pic0
FROM $table
WHERE performerid IS NOT NULL
$categorySql $buildSql
$breastsize $haircolor $age $ethnicity
$willingnessSql)
ORDER BY sort_col)
) AS t
关于php - 计数mysql联合类型查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8580039/