Page 1 of 1

Table field exists?

Posted: Sat Oct 27, 2007 11:09 pm
by kkonline
Is it possible to know whether a particular table field exista in a table or not?

Secondly is it possible to display all the table fields existing in the table.

I have a table called articles inside a database named mysql
I want to display all the table fields present in articles or check whether a particular field exists. How to do?

Posted: Sat Oct 27, 2007 11:13 pm
by feyd
Look at the DESCRIBE statement.

Posted: Sat Oct 27, 2007 11:27 pm
by seppo0010

Code: Select all

SHOW COLUMNS IN `table`
can be more useful, at least in MySQL. At first sight they both return the same thing, but you can use

Code: Select all

SHOW COLUMNS IN `table` LIKE 'fieldname';
http://dev.mysql.com/doc/refman/5.0/en/describe.html
http://dev.mysql.com/doc/refman/5.0/en/ ... lumns.html