简体   繁体   中英

SQL View not displaying all count results

I've created a view in phpMyAdmin, and there is 37 results in the table that the view is of, but it's only showing 30 results in the count.

If I type a statement as follows

SELECT COUNT(*) FROM `vwk_activity` LIMIT 0,30

that displays that the count is 37 results, but if I try

SELECT COUNT(*) FROM `vwk_activity` LIMIT 30,30

it returns empty. If I type

SELECT COUNT(*) FROM `vwk_activity` LIMIT 50

That also returns 37.

This is an example of what I'm trying to do

// Set Page Limit
$page_limit = 30;
// Get Page Number
if (!isset($_GET['page']) ){$start=0;} else {$start = ($_GET['page'] - 1) * $page_limit;}
/* Check if Activity in DB */
try {
    $rs_check = $dbh->prepare("SELECT COUNT(*) FROM `vwk_activity` LIMIT ".$start.",".$page_limit);
    $rs_check->execute();
} catch (PDOException $e) {
    print "There was an error: " . $e->getMessage() . "<br/>";
    die();
}
$total = $rs_check->fetchColumn();

This works for plenty of my other pages, but it's not working on this one for some reason.

select count(*) returns the record count in a table back to you in a single row...not 1 row per record counted. If the count was 20 million, it would return 1 row with 20 million in it.

So this query is only returning 1 row. Limit 0,30 and limit 50 both return the first and only row saying 37. Limit 30,30 will return nothing in this case as it returns 30 rows from row 30 (which doesn't exist because this only returns one row)

Try select * from ... if you want to see 1 row for each record.

Try this in config.inc.php:

$cfg['MaxExactCountViews'] = 1000;

By default, phpMyAdmin does not count the number of rows for view, which produces problem in the navigation. With this value, you should be seeing navigation control to reach the seven missing rows.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM