Reputation: 151
I have this query which I am getting the count of the number of songs clicked is it possible to get the number of rows returned? as my host doesn't allow query that take a long time so I was thinking to get the number of rows then run the query again and offset it to get the next 50 and so on
SELECT mv.id, mv.songname, mv.slug, (SELECT Count(*) FROM clickedsongname WHERE clickedsongname.songid = mv.id) Count FROM videoname mv;
I've tried doing this to get the count:
SELECT count(*) mv.id, mv.songname, mv.slug, (SELECT Count(*) FROM clickedsongname WHERE clickedsongname.songid = mv.id) Count FROM videoname mv;
and
SELECT count(*) mv.id, mv.songname, mv.slug, (SELECT Count(*) FROM clickedsongname WHERE clickedsongname.songid = mv.id) Count FROM videoname mv as overallcount
Upvotes: 1
Views: 546
Reputation: 135
You can use some built in PHP MySQLi functions.
#define the connection
$con = mysqli_connect("ip","user","pass","dbname");
#define the query
$query = '(query that gets rows)';
#run the query
$result = mysqli_query($con, $query) or die(mysql_error());
#Get the row count
$rows = mysqli_num_rows($result);
print_r($rows);
Hope this helps!
Upvotes: 1