tags:

views:

189

answers:

2

Hi friends,

i want to get the column data type of mysql table.

Though MYSQLFIELD structure but it was enumerated field types.

then i tried with "mysql_real_query() "

for me the error which i am getting is "query was empty"

pls help to get the column data type

thanks in advance

krishna

+2  A: 

The query below returns a list of information about each field, including the MySQL field type. Here is an example:

SHOW FIELDS FROM tablename
/* returns "Field", "Type", "Null", "Key", "Default", "Extras" */

See this manual page.

James Skidmore
An alternative is EXPLAIN tablename;
hobodave
+1  A: 

You can use the information_schema columns table:

SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS 
  WHERE table_name = 'tbl_name' AND COLUMN_NAME = 'col_name';
Don't forget: AND INDEX_SCHEMA = 'database_name'
Inshallah