[SOLVED]Referencing columns by number not name

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
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

[SOLVED]Referencing columns by number not name

Post by Skittlewidth »

Quick question:

If you want to write a select statement for a table you don't know the column names for, how do you format the statement so that you use the column numbers, as you could with an array? The manual was a bit vague. So instead of writing

Code: Select all

select * from tablename order by id
it would be more like

Code: Select all

select * from tablename order by 0
Thanks
Last edited by Skittlewidth on Mon Oct 17, 2005 10:35 am, edited 1 time in total.
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

ah the column numbers start at 1 not zero....
Post Reply