Mitul Dabhi
answered Nov 30 '-1 00:00
is MySQL have typeof function ? -- No MySQL dont have such function which return column data type
But By Query we can achieve it
study following Query ::
SELECT DATA_TYPE FROM information_schema .`COLUMNS` WHERE TABLE_SCHEMA='wp_database' AND TABLE_NAME='wdp_postmeta' and COLUMN_NAME='meta_value'
information_schema is database which store metadata about the all databases
so information_schema has COLUMNS table which have schema for all columns
so at column table we need to filter our column by its database --> table --> column
so
COLUMNS table have column like
TABLE_SCHEMA which have database name
TABLE_NAME which have table name
COLUMN_NAME which have column name
so we can write filter query in where like this
WHERE TABLE_SCHEMA='databasename' AND TABLE_NAME='tablename' and COLUMN_NAME='column name'
and COLUMNS have column DATA_TYPE which have data type of that column
so our needed Query is
SELECT DATA_TYPE FROM information_schema .`COLUMNS` WHERE TABLE_SCHEMA='wp_database' AND TABLE_NAME='wdp_postmeta' and COLUMN_NAME='meta_value'
information_schema(database) >> COLUMNS (table)
have 19 column which store differ characteristic of every table 's columns