SQL View no muestra todos los resultados de conteo

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.

Este es un ejemplo de lo que estoy tratando de hacer.

// 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);
} catch (PDOException $e) {
    print "There was an error: " . $e->getMessage() . "<br/>";
$total = $rs_check->fetchColumn();

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

preguntado el 09 de septiembre de 13 a las 22:09

I think I need you to write out what you are trying to accomplish in English. You are querying for what? If you are expecting to find something with limit 30,30 you must then be expecting to have your query return more than 30 rows. A count(*) without a group by always returns one row...so of course limit 30,30 is empty. -

@Twelfth oh $*** I'm such a W***** today. What an idiot. I've now realised what you've been saying. Thanks for the help! -

2 Respuestas

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.

Respondido el 09 de Septiembre de 13 a las 22:09

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.

Respondido el 10 de Septiembre de 13 a las 01:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.