- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I get the list of columns from a table in the other database than we
are currently using IN operator?
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)
Advertisements