简体   繁体   English

PHP mysql_num_rows其中等于

[英]PHP mysql_num_rows WHERE this equals this

Is it possible to do something like the WHERE clause in a mysql_num_rows statement in PHP? 是否可以在PHP的mysql_num_rows语句中执行类似WHERE子句的操作? For example, say I have the column "number" in my database. 例如,假设我的数据库中有“数字”列。 I want to use mysql_num_rows($number) to display how many rows have the number 1. I know the other ways to do this, but it would be much much easier for what I'm doing to be able to use mysql_num_rows with a WHERE clause. 我想使用mysql_num_rows($ number)来显示多少行具有数字1。我知道其他方式可以这样做,但是对于我正在做的事情,能够在WHERE中使用mysql_num_rows会容易得多。条款。

SELECT COUNT(*) cnt FROM tablename WHERE rowname = 1

使用此查询,您不需要 mysql_num_rows ,这在不需要数据本身但需要行数的情况下会增加开销

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

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