如何检查表是否为空? [英] How to check if a table is empty?

查看:93
本文介绍了如何检查表是否为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想检查表是否为空?


在我的表中(即测试)有没有记录和id是主键和自动增量列。


i用来查找从测试中选择计数(id)


它给出1。


另外使用别人查询但只能得到答案1


怎么找?

Hi Guys,

I want to check if a table is empty or not?

In my table (i.e test) have no records and id is a primary key as well as auto increment column.

i have using to find this "select count(id) from test"

It gives 1 .

ALso using others query but only get answer 1

how do find ?

推荐答案

我认为您在错误的论坛中发布了您的问题。这似乎是一个数据库问题,而不是PHP问题。您可能希望在其他地方发布。
I think you posted your question in the wrong forum. It seems to be a database issue, not necessarilly a PHP issue. You may wish to post this elsewhere.


我在mysql中测试它,没关系......

I test it in mysql,it''s ok...

展开 | 选择 | Wrap | 行号


当然,Coolist是对的。这不属于PHP论坛,而是属于其中一个数据库论坛。

考虑到这是在PHP论坛中发布的,我现在已将其移至MySQL论坛。请告诉我它是否应该在其他地方请。


关于你的问题,使用COUNT函数应该可以得到你需要的结果。

那是,如果你这样做:
Coolist is quite right, of course. This would not belong in the PHP forum, but rather in one of the database forums.
Considering that this was posted in the PHP forum, I have moved it over to the MySQL forum for now. Let me know if it should be somewhere else please.

As to your question, using the COUNT function should give you the results you need.
That is, if you were to do:
展开 | 选择 | Wrap | 行号


这篇关于如何检查表是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆