Access column with table name? (postgreSQL)

i must use a single query for time-saving.

but how could i access the field by table name?

as example if me want store this data in a class object.

Ashampoo_Snap_Sonntag, 6. Juni 2021_17h55m51s_003_Xojo - TestDatabase

You could change your query to say

Table1.data as T1Data, Table2.data as T2Data

@Greg_O_Lone
it seems i have no other choice.
do you have the possibility to add a table name in DatabaseColumn?

There may be a command you can send to Postgres to do that. Can’t remember off the top of my head.

1 Like

i found this syntax to rename the columns but it is worrying …

select t1.* from table1 t1 (a,b)

You can also do
Select t1.a as “t1.a”,t2.a as “t2.a”. But you’d have to do this on a field by field basis.
BTW, there is no point in asking the Xojo developers to alter the SQL standard.

1 Like

sure there is, vb6 respectively DAO can handle this via odbc at least i can remember.
if you join tables the fields was accessible by tablename.fieldname without using “As”.
in xojo if me have two tables with standardised address struct the problems starts.
if me want create objects (OOP …) via method from a row its no fun. (all fields have to be renamed to be unique)
however, i have to rework my listview filling one way or the other.

If I got it right, you have a sql statement stored in a class ?
if so, I store it as ‘@@name@@.column-name’ and before processing I replace the variable ‘@@name@@’ to the proper table name, that might help …

1 Like

for this oop transfer i used once select * where id to load data into
and to make it faster i gave the rowset to a method.
it looks like

.data = rs.Column("data").StringValue

i think i can change it to

.data = rs.Column(prefix+“data”).StringValue

using all columns with “As” and give my method this prefix string.
if me not using “As” i can let this prefix empty.