So far I got it working with a subselect, but some research told me it is bad to be using subselects (especially on large tables) as they are less performant.
Now that's what I got:
SELECT COUNT( riddims.riddim ) AS rc,
(
SELECT COUNT( tunes.tune )
FROM tunes
WHERE tunes.tune NOT
IN (
''
)
) AS tc
FROM riddims
WHERE riddims.riddim NOT
IN (
''
)
The tables look something like:
riddims:
riddim | genre | image
tunes:
riddim | artist | tune
I was playing around with 'JOIN' but couldn't realy figure a working query out. What I'd need is something similiar to STACKOVERFLOW COUNT FROM MULTIPLE TABLES in a more performant way than my above solution.
My goal is to perform a query that shows following output:
riddims | tunes | artist
100 | 400 | 2
- WHERE riddims NOT IN ('')
- WHERE tunes NOT IN('')
- WHERE artist = 'some artist'
This is how I started but its obviously going into the wrong direction:
SELECT COUNT(riddims.riddim) AS rc, COUNT(tunes.tune) AS tc FROM riddims LEFT JOIN tunes ON riddims.riddim = tunes.riddim