Simple question: How can I return the field type of a MySQL table. I know about describe
or show column
but I just want to return that single parameter. e.g.:
SELECT fieldtype(mycol) FROM mytable
# should return INT or integer for example
Simple question: How can I return the field type of a MySQL table. I know about describe
or show column
but I just want to return that single parameter. e.g.:
SELECT fieldtype(mycol) FROM mytable
# should return INT or integer for example
You can get this from the information_schema database:
You can use
This will return you result in format of
The following syntax also works, using describe, enter the columnName after the tableName:
I know I'm a little late to the party. You may want to use COLUMN_TYPE rather than DATA_TYPE. It gives more info (such as precision) about the type.
...yields...