Table field exists?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Table field exists?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Look at the DESCRIBE statement.
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post 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
Post Reply