I'm trying to get ten rows of data from my database that meet a certain criteria. I'm trying to get the first ten users who are registered in the database to take a course, but I also want to get the total number of users taking the course from the database. I know to use limit to return only ten users, but is there any way I can avoid doing two queries in order to also get the total number of users taking the course. My current query is below.
SELECT * FROM users, user_courses
WHERE users.id = user_courses.user_id AND user_courses.CRN = '$CRN'