List:General Discussion« Previous MessageNext Message »
From:Kelly Jones Date:May 14 2007 12:25am
Subject:SELECT statement returning columns for a given table?
View as plain text  
In PostgreSQL, the following SELECT statement will return all the
columns for 'tabname':

SELECT x.attname FROM pg_attribute x, pg_class y WHERE
x.attrelid=y.oid AND relname='tabname';

Does MySQL have anything similar?

I know about "SHOW COLUMNS FROM tabname", but am looking for something
more SQL-y, because I want to use the results as part of a larger SQL
statement. For example, I want to find all the tables in a given db
that don't have a column named 'timestamp'.

I thought the 'mysql' system db may have this info, but it doesn't seem to.

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
Thread
SELECT statement returning columns for a given table?Kelly Jones14 May
  • Re: SELECT statement returning columns for a given table?Baron Schwartz14 May
  • Re: SELECT statement returning columns for a given table?Peter Brawley14 May