-5

hi guys the query only return one rows even i have 12 rows. Please help

$connection = mysqli_connect("localhost","root","","database");
$qry="SELECT COUNT(*) as count FROM table";
$result=mysqli_query($connection, $qry);
  • 2
    COUNT is an aggregation function, it's going to aggregate all rows unless you use groupings. – Devon Aug 17 '18 at 16:53
  • You dont actually get the information that that query returns. You need to do some sort of fetch to get the actual count – RiggsFolly Aug 17 '18 at 17:29

1 Answers1

-2

As Devon mentioned, COUNT is an aggregate function, so it will only return 1 row. If you want to retrieve all 12 rows, do:

SELECT * FROM table;
Gordan Lin
  • 27
  • 6