how to return row count of mysql sub query

I have the following SQL query:

SELECT games.id, games.GameTitle FROM games 
WHERE EXISTS (
              SELECT filename FROM banners 
              WHERE banners.keyvalue = games.id 
                AND banners.filename LIKE '%front%'
             )

which is not quite correct for my use

what I'd like is something like:

SELECT games.id, games.GameTitle 
FROM games WHERE EXISTS (
    COUNT(SELECT filename FROM banners 
    WHERE banners.keyvalue = games.id AND banners.filename LIKE '%front%') > 1
    )

i.e. only select when the subquery retrieves more than 1 row.

5
задан Johan - reinstate Monica 26 May 2011 в 21:07
поделиться