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?
我正在尝试找到一个解决方案,让总行受影响的查询没有“limit”子句和带有limit子句的查询记录...如何做到没有2个查询(count(*)和主查询?
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");
1 个解决方案
#1
0
Try with mysql_affected_rows
like
尝试使用mysql_affected_rows
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.
并且尽量避免使用mysql_ *函数,因为它们已被弃用。而是使用mysqli_ *函数或PDO语句。
#1
0
Try with mysql_affected_rows
like
尝试使用mysql_affected_rows
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.
并且尽量避免使用mysql_ *函数,因为它们已被弃用。而是使用mysqli_ *函数或PDO语句。