更新时间:2023-01-29 16:54:54
From the docs for version 5.0 (http://dev.mysql.com/doc/refman/5.0/en/show-columns.html)
"SHOW COLUMNS displays information about the columns in a given table"
因此您不能真正在多个表上使用它.但是,如果您有information_schema
数据库,则可以按如下方式使用它:
So you can't really use it on multiple tables. However if you have information_schema
database then you could use it like follows:
select column_name
from `information_schema`.`columns`
where `table_schema` = 'mydb' and `table_name` in ('users', 'posts');
在这里,您必须将mydb
替换为您的数据库名称,或者只使用DATABASE()
.
Here you'd have to replace the mydb
with your database name, or just use DATABASE()
.