Chrome Extension

Show all column names of a table MySql query

There are a lot of ways to get all the column names of a table in MySql. The simplest one is using DESCRIBE of Mysql and place table name after that.
-- First method
DESCRIBE table_name;

-- Second method
SHOW COLUMNS FROM table_name;

-- Third method
SELECT column_name
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME = 'table_name';

-- Get column names in a single line (comma seperated)
SELECT group_concat(column_name)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME = 'table_name';
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Using the code we are trying all the column names that exist in a table.

Was this helpful?
0 Comments
Join Devsheet Ask a Question