All pastes #418763 Raw Edit

Unnamed

public text v1 · immutable
#418763 ·published 2007-03-31 20:32 UTC
rendered paste body
SELECT * 
  FROM invusers AS t1
  JOIN invads AS t2 ON t1.invid = t2.invid, invareas AS t3
  JOIN t1 ON t1.invid = t3.invid
  LEFT JOIN (SELECT invusers.invid, 
              COUNT( invareas.invid ) cnt
               FROM invusers
               LEFT JOIN invareas ON invusers.invid = invareas.invid
              GROUP BY invusers.invid
             ) AS t4
 WHERE t1.perm >0
   AND t2.expires > curdate( ) 
   AND t2.approved =1
   AND t3.city = 'garland'
   AND t3.state = 'TX'
 ORDER BY t4.cnt ASC ;