Re: column number instead of column name
От | Michael Fuhr |
---|---|
Тема | Re: column number instead of column name |
Дата | |
Msg-id | 20060121052246.GA20004@winnie.fuhr.org обсуждение исходный текст |
Ответ на | column number instead of column name (First Last <y2kdis@atenista.net>) |
Список | pgsql-novice |
On Fri, Jan 20, 2006 at 12:24:37AM -0800, First Last wrote: > how can i make use of the column number instead of the column > name when making the select statement? > > for instance: > "SELECT mytable.col[1], mytable.col[2], mytable.col[3], mytable.userid from mytable" I don't think you can do that in ordinary SQL, but you could query the system catalogs to get the table structure and generate a list of column names from that. > i have several tables and i need to extract the first three columns > and a known column. the first three columns for the different tables > vary, but all the tables have the userid column. Can you tell us a little more about what you're doing? Some people would question this design, arguing that a relation's attributes should be referenced by name and that the order in which they happen to be stored should be irrelevant and not relied upon. However, without knowing what you're doing it's hard to insist that such a generalization should apply to your case. -- Michael Fuhr
В списке pgsql-novice по дате отправления: