I'm trying to find a solution to have total rows affected of a query without the "limit" clause and the records of the query with limit clause... How to do that without 2 queries (count(*) and main query?
Thanks
EDIT: Here is my query:
$result = mysqli_query($link,"SELECT DISTINCT p.*
FROM posts p
JOIN abos a
ON p.userid = a.blogid OR p.userid = 11
LEFT JOIN posts_denied r
ON r.post_id = p.id AND r.userid = 11
WHERE (a.userid = 11 OR p.userid = 11)
AND r.post_id IS NULL
ORDER BY p.id DESC
LIMIT 5");
Try with mysql_affected_rows
like
mysql_query($sql_query);
echo "Number of rows effected = ".mysql_affected_rows();
See this LINK
And try to avoid using mysql_*
functions due to they are deprecated.Instead use mysqli_*
functions or PDO
statements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.