mysql中select column_name from Information_schema.columns where table_Name = 'test'出现多个字段的问题

来源:互联网 发布:centos安装h.264 编辑:程序博客网 时间:2024/04/29 13:49

在mysql中,通过sql查询某个表字段时,会出现一些这个表中没有的字段

例:

select column_name from Information_schema.columns  where table_Name = 'test';

因为这个表在其它库中也存在了,所以会出现多余的字段。


解决办法:

select column_name from Information_schema.columns  where table_Name = 'test'and TABLE_SCHEMA='dbname';

指定当前数据数据库就可以了(dbname为我当前数据库名)。

0 0
原创粉丝点击