[英]How count many rows returned in select of Mysql?
can you suggest me how count rows returned in select of Mysql ? 您能建议我如何选择Mysql中返回的行数吗?
$n_quakes = "SELECT COUNT(*)
FROM earthquakes
WHERE milliseconds >= 1000
AND milliseconds <= 2000
AND magnitude >= 4
AND magnitude <= 8
AND ipocentro >= 50
AND ipocentro <= 800
AND latitude >= 40
AND latitude <= 50
AND longitude >= 30
AND longitude <= 70";
In this way i'll know number of rows ? 这样我会知道行数吗?
In my code doesn't work but i don't no if this is error or is in other place of code. 在我的代码中不起作用,但是如果这是错误的或在其他代码中,我不会。
Thanks for help and sorry for my english 感谢您的帮助,对不起我的英语
Try this using between 尝试使用之间
$count = mysqli_fetch_array(mysqli_query($coni, "SELECT COUNT(*) as totalCount
FROM earthquakes
WHERE (milliseconds between 1000 and 2000) and (magnitude between 4 and 8) AND (ipocentro between 50 and 800) AND (latitude between 40 and 50) and (longitude between 30 and 70)"));
$actualCount = $count['totalCount'];
尝试以下代码,其中mysqli_num_rows返回行数,$ con为数据库连接变量
$n_quakes = mysqli_num_rows(mysqli_query($con, "SELECT id FROM earthquakes WHERE milliseconds >= 1000 AND milliseconds <= 2000 AND magnitude >= 4 AND magnitude <= 8 AND ipocentro >= 50 AND ipocentro <= 800 AND latitude >= 40 AND latitude <= 50 AND longitude >= 30 AND longitude <= 70"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.