Is there a way to write a query in sql that will return the column names for the table?
e.g. if table Foo had columns bar and baz, this query would return 2 rows with "bar" and "baz" in them.
Is there a way to write a query in sql that will return the column names for the table?
e.g. if table Foo had columns bar and baz, this query would return 2 rows with "bar" and "baz" in them.
Generally you can use the INFORMATION_SCHEMA
tables for this. Not all databases implement them however. Which database are you using?
one way that will work on SQL Server, PostgreSQL and MySQL (might work on others too, will not work on Oracle)
select * from information_schema.columns
where table_name = 'Foo'