Select UserID, (select count(*) from names where userid = userid) as totalcount from users where firstname like '%john%'
The error is "where userid = userid". I don't know how to word this. UserID's are unique accross both tables. I want to return results for all firstnames like "%john%" out of my Users table, and also, for each record, I want the count(*) from names for that same UserID.
Open in new window