select columns

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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

select columns

Post by Luke »

How would you select all the columns from a certain table? I tried "SELECT COLUMNS AS something() FROM table" and "SHOW COLUMNS FROM table" and neither worked!

How do I get all columns from the table in an array?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

DESCRIBE `table`
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

You can also do a select from the information_schema database (assuming mysql):

Code: Select all

SELECT column_name FROM COLUMNS WHERE table_schema='database_name' and table_name='table_name'
Post Reply