list all columns in a table mysql code example

Example 1: get the mysql table columns data type mysql

SHOW COLUMNS FROM mydb.mytable;

Example 2: MySql get fields of table

SELECT COLUMN_NAME
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table';

Example 3: mysql all columns

-- MySQL
SELECT * 
FROM INFORMATION_SCHEMA.COLUMNS;

Example 4: list in one column mysql

country table
-------------
id
name
other_column


rule table
----------
id
name
other_column


countryrules table
------------------
country_id
rule_id

Tags:

Sql Example