I have the following query:
$sql = "SELECT first, COUNT(FIRST) FROM techs INNER JOIN ros ON techs.id = ros.writtenby GROUP BY ID";
That gives the desired output of:
first | COUNT(FIRST) |
---|---|
Eric | 88 |
John | 11 |
I have no earthly idea how to display this EXACT table onto a PHP/HTML page. I've created tables based off of queries but it's basically just displaying database table data. I have a feeling the INNER JOIN is the root of my issue since it's not an actual table in the database, rather just results from my query. If this isn't apparent enough already I'm very much a beginner at coding in general so be kind. Lol.
CodePudding user response:
From comments:
I don't understand how to call and then display the "
count(first)
" column of my query results, since "`count(first)" isn't an actual column in either of the tables I am generating the result from.
If only that's your problem, use alias, like:
SELECT first, COUNT(FIRST) AS my_count FROM techs INNER JOIN ros ON techs.id = ros.writtenby GROUP BY ID
Note that above is the query you posted, just with "
AS my_count
" added.