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

Utilisation incorrecte de UNION et ORDER BY ?

Essayez avec :

(
  select 
    * 
  from 
     _member_facebook 
   inner join 
     _member_pts 
   ON 
     _member_facebook._fb_owner=_member_pts._username 
  where 
    _member_facebook._promote_point = 9 
  ORDER BY RAND() 
  limit 2
) 
UNION ALL
(
  select 
    * 
  from 
    _member_facebook 
   inner join 
    _member_pts 
   ON 
     _member_facebook._fb_owner=_member_pts._username 
  where 
    _member_facebook._promote_point = 8 
  limit 3
)

Bien que je pense que vous devriez mettre le ORDER BY clause à la fin de la deuxième requête