# How can I get the list of columns from a table in the other database than we are currently using IN operator?

MySQLMySQLi Database

It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows:

Syntax

SHOW COLUMNS FROM tab_name IN db_name

Here,

• tab_name is the name of the table from which we want to see the list of columns.
• Db_name is the name of the database, in which the table is stored

Example

In the example, we are currently using the database ‘query’ and getting the list of columns
from a table named ‘arena’ stored in MySQL ‘database’:

mysql> SHOW COLUMNS FROM arena IN mysql\G
*************************** 1. row ***************************
Field: id
Type: int(10) unsigned zerofill
Null: NO
Key: PRI
Default: NULL
Extra  : auto_increment
*************************** 2. row ***************************
Field: Photo
Type: blob
Null: YES
Key:
Default: NULL
Extra:
2 rows in set (0.08 sec)
Published on 21-Feb-2018 10:32:37