EDIT: Detailed description
Detailed Description:
*in table_a there are 100 members but only 50 of them have records in table_b and only 25 have records in table_b where approved = 1 THEREFORE the value I will need returned by the query is 25*
Hey everyone here is the query I am trying to resolve it will need to return a single result count so I can access with mysql_result($query, 0).
SELECT COUNT(id) FROM table_a WHERE (THIS IS WHERE I AM STUCK)
I need to check if the( count of memberID in table_b WHERE memberID matching each id in table_a and approved in table_b = 1) - is greater than 1
The final result needs to be a count of the number of members that have an entry in table_b.
Sample of table columns that need to access
table_a
-----------------
id
table_b
------------------
id
memberID
approved
Let me know if you need any more details.
Problem Solved
Had to think of it backwards
SELECT COUNT( DISTINCT memberID )
FROM table_b
WHERE approved =1
I do not need to even look at table_a seeing as I am counting the memberID based on table_b
Sometimes the solution is so simple and right in front of you.
Thanks for all the help! I hope this helps other in the future.
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