Mysql
 sql >> Base de données >  >> RDS >> Mysql

Compter la requête de type union mysql

Comptez simplement les résultats de la sous-requête...

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