简体   繁体   English

如何选择带有数据的所有表行以显示带有数据的总数

[英]How can I SELECT all table rows with data to display total number with data

I'm trying to show the total amount of say people with kittens. 我试图显示说有小猫的人的总数。

$query = mysql_query("SELECT * FROM people.kittens WHERE IS NOT NULL");

The issue is the field is not set to NULL and is either blank or has data. 问题是该字段未设置为NULL并且为空或有数据。 Then I would show the total number with: 然后,我将显示总数:

$Totalpeoplewithkittens = mysql_num_rows($query);

I know mysql_query is outdated. 我知道mysql_query已过时。 Just testing/learning. 只是测试/学习。

关于什么

$query = mysql_query("SELECT count(kittens) FROM people WHERE kittens > ''");

像从...选择计数(*)一样使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从有条件的表中选择所有数据? - How can I select all the data from a table with condition? 如何计算具有相同列数据的行数并显示到表? - How to count number of rows with the same column data and display to table? 在3列的表格中显示数据,N行 - Display data in a table in 3 columns, N number of rows 如何获取数据的所有行? - How can I fetch all the rows of the data? 如何显示带有从ID中提取数据的表中选择数据的弹出窗口? - How can I display popup window with select data from table that fetch data from ID? 如何选择所有表格的行? - How can I select all table's rows? 使用数据表通过脚本选择行以选择/选择所有行进行列出,然后如何设置/获取所选行的动态ID - using data-table for listing with select/selectall rows for rows selection by script, then how can i set/get dynamic ids of selected rows PHP SQL如何在使用CASE和表JOIN时获得总行数 - PHP SQL how i can get total number of rows when using CASE and table JOIN 如何从数据库表中获取行数并使用 UPDATE 查询将总行数插入到不同表的列中 - How can I fetch the number of rows from a database table and insert the total rows into columns of a different table using UPDATE query 我如何从mysqltable中选择所有数据并在html上显示它们 - how can I select all the data from mysqltable and display them on html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM