Click to See Complete Forum and Search --> : SQL question


grim_fandango
02-13-2002, 04:06 PM
is there any SQL command that can return a column name?
like if tables have 4 columns: ID, name, price, qty
i need a function/sql statement that can return those strings (column name) but i never seen this before...
so does it exist in sql?
thanks

Grizzly
02-13-2002, 08:47 PM
This depends on what DBMS you're using. For example, I know under Oracle, you can simply say "desc <tablename>" and it will spit out the table structure for you.

I've always been curious if MySQL had some equivilent to that...but I haven't found it.

What exactly are you trying to accomplish?

mefisto3
02-13-2002, 09:21 PM
MySQL has:

describe <tablename>

which also outputs the table info.

krack_it_up
02-19-2002, 10:50 AM
MS SQL has quite a few options as well, you can try this

SELECT a.name
FROM syscolumns a
JOIN sysobjects b
ON a.id = b.id
WHERE b.name = '<tablename>'
AND b.type = 'U'

This will give you a list of all the columns in a table.

grim_fandango
02-19-2002, 07:11 PM
i'm using Access database and VB for the program