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.
SELECT FUCNTIONIMLOOKINGFOR(SELECT * FROM anothertable) AS count FROM table; So that count is an integer of how many rows the subquery SELECT * FROM anothertable returns.
The COUNT(*) function returns the number of rows in a result set returned by a SELECT statement. The COUNT(*) returns the number of rows including duplicate, non-NULL and NULL rows.
To counts all of the rows in a table, whether they contain NULL values or not, use COUNT(*). That form of the COUNT() function basically returns the number of rows in a result set returned by a SELECT statement.
Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count. Do the same thing to count columns, but this time click the row selector at the left end of the row. If you select an entire row or column, Excel counts just the cells that contain data.
Simply like that :
SELECT games.id, games.GameTitle
FROM games
WHERE (
SELECT COUNT(filename)
FROM banners
WHERE banners.keyvalue = games.id AND banners.filename LIKE '%front%'
) > 1
SELECT games.id, games.GameTitle
FROM games
WHERE EXISTS (SELECT COUNT(filename)
FROM banners
WHERE banners.keyvalue = games.id
AND banners.filename LIKE '%front%'
HAVING COUNT(filename)>1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With