我肯定失去了一些东西真的很明显,但我有这个非常基本的MySQL查询:计数MySQL表总是返回零?
SELECT count(*) from information_schema.tables WHERE table_schema == "my_table";
然而,此查询总是返回零,即使“MY_TABLE”的存在。我在这里错过了什么?
我肯定失去了一些东西真的很明显,但我有这个非常基本的MySQL查询:计数MySQL表总是返回零?
SELECT count(*) from information_schema.tables WHERE table_schema == "my_table";
然而,此查询总是返回零,即使“MY_TABLE”的存在。我在这里错过了什么?
在特定模式(数据库)中搜索表。您必须在查询中提供TABLE_SCHEMA
。
SELECT count(*) from information_schema.tables where table_name = 'my_table' and table_schema = 'database_name'
还要执行SELECT * from information_schema.tables
来查看其他信息表中包含的内容。
使用单个=
运算符在哪里条件。尝试此查询
SELECT count(*) from information_schema.tables WHERE table_schema = 'my_table';
了解它的更多信息Official Link
双==
的问题。这不是C/C++ :-)
当我运行SELECT table_schema from information_schema.tables
时,它返回数据库名称,而不是表名称。
我觉得@Vicky Thakor吧。 – Zuiche
double =操作符被错误地留下,但添加tale_schema做了诀窍。 :) –