开发者

mysql select all table names except

Alright, I know you can do the following to get all column names.

SHOW COLUMNS FROM person;

However, it does not allow where statements.

Is there any way to get the full list and just say not this one?

So I am basically looking for something like this:

select (show columns from person where Field <> '开发者_如何学Goid') from person


USe SHOW [FULL] COLUMNS {FROM | IN} tbl_name [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]
Example:

SHOW CHARACTER SET WHERE `Default collation` LIKE '%japanese%';

More about show here

Try something like SHOW COLUMNS FROM person WHERE column != 'value';


Or you can use proper a SQL query against information_schema

select * from information_schema.columns
where table_schema = 'test'    # your db name
and table_name = 'person '
and column_name != 'id'

For MySQL 4, you can use LIKE directly instead of WHERE http://dev.mysql.com/doc/refman/4.1/en/show-columns.html

SHOW COLUMNS FROM 'Person' LIKE '%x%'

However unfortunately, that does not support a NOT clause.

If I may suggest

  • If you need this information from MySQL console/phpAdmin/equivalent, just eyeball it..
  • If you need this from a front-end program like php, do it from that environment.


MySQL documentation says that WHERE clause is allowed. Read the docs.


You cannot perform a true SHOW COLUMNS WHERE in MySQL 4. The docs show only an optional LIKE parameter for that version: http://dev.mysql.com/doc/refman/4.1/en/show-columns.html

However, you can use the metadatabase information_schema.

USE information_schema;
SELECT * FROM `COLUMNS` WHERE `TABLE_NAME` = 'person' AND `COLUMN_NAME` != 'value';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜