On 2016-03-24 Adam Thompson wrote:
IIRC, on SQL-92-compliant databases (which MySQL 5.5 is *not*, but this syntax might work anyway), the correct syntax will be:
SELECT a.firstcolumn , (SELECT count(*) FROM firsttable AS b WHERE b.firstcolumn =
Thanks Adam and John! I was so set on finding a join way I had forgotten about subqueries. Those ideas look like they will work fine.
I once heard every subquery can be done as a join... how would you do the above with just joins (and without views)? Impossible? That's what I was trying to figure out and I just couldn't make it work. (Note, I wouldn't mind subqueries in the WHERE, to pull out sets, etc, but it would be nice to avoid the subqueries in the SELECT as they have to be run for every row the join/where selects, giving me, I think, O(n^2).
Maybe my first hunch was correct and it's impossible to "flatten" this type of thing down to 1 simple-style query?