Print Thread
How select fields from 2 tables with the identicel name
#1745 03/05/01 05:51 PM
Joined: Mar 2001
Posts: 2
W
Member
OP Offline
Member
W
Joined: Mar 2001
Posts: 2
I have two tabels
exempel
SQL:

Select *
From Auftrag1 Auf1, Auftrag2 Auf2
Where Auf1.AufNr = Auf2.AufNr
Order by Auf1.Aufnr

after execute I would get the Field with the Name "Status" from Auftrag1 and Auftrag2

How can I do this
With the function
Text1 := FieldAsString('Auf1.Status')
Text2 := FieldAsString('Auf2.Status')
I get the Replay Field 'Auf1.Status' don

Re: How select fields from 2 tables with the identicel name
#1746 03/06/01 12:26 PM
Joined: Oct 1999
Posts: 7
Ventspils, Latvia
V
Member
Offline
Member
V
Joined: Oct 1999
Posts: 7
Ventspils, Latvia
if You try to select like

example
table1
nr number
status varchar2(1)

after query
select * from table1 a, table1 b
where a.nr = b.nr

You get cursor with fields
nr,status,nr_1,status_1

because each column must be unique identified by name and there is more then 1 column with this name

And You can't define alias name AFTER query execution

in your example
Text1 := FieldAsString('Status')
Text2 := FieldAsString('Status_1')

Best regards
Vents Lauva


[This message has been edited by Vents Lauva (edited 06 March 2001).]

Re: How select fields from 2 tables with the identicel name
#1747 03/06/01 02:32 PM
Joined: Sep 2000
Posts: 52
London, UK
J
Member
Offline
Member
J
Joined: Sep 2000
Posts: 52
London, UK
You will be better aliasing your columns explicitly. e.g.

Select
auf1.status status1,
auf2.status status2
From Auftrag1 Auf1, Auftrag2 Auf2
Where Auf1.AufNr = Auf2.AufNr
Order by Auf1.Aufnr


Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.032s Queries: 13 (0.007s) Memory: 2.5051 MB (Peak: 3.0424 MB) Data Comp: Off Server Time: 2024-05-14 16:45:14 UTC
Valid HTML 5 and Valid CSS