shantanuo
shantanuo

Reputation: 32316

list all column names

select * from tbl

Is there an easy way to list all the column names from the table that will look like this?

select colA, colB, colC from tbl

Upvotes: 1

Views: 1597

Answers (2)

Mike B
Mike B

Reputation: 12797

I'm not sure what you mean by listing the column names. As already mentioned to list the data within all columns you'll need to write:

select * from table

Whereas if you'd like a list of just the columns in your table, give these a try:

show columns from table

or

describe table

More information on the latter can be found here

http://dev.mysql.com/doc/refman/5.0/en/show-columns.html

http://dev.mysql.com/doc/refman/5.0/en/describe.html

Upvotes: 1

Chris Gutierrez
Chris Gutierrez

Reputation: 4755

I'm completely sure what you mean by "list". To select all the columns you could do

SELECT * FROM tbl

or if you want list all of the columns and their types you can use

DESCRIBE tbl

Upvotes: 0

Related Questions