Outer join problem with 2 different alias for same table.



Hi,

I am testing a SQL query on 2 "almost" identical databases. The SQL
query is made by a Java ORM framework (Hibernate), so I dont have too
much control over it. I know the query is very strange because it only
try to make a join between 2 primary key.

The problem is that this query is working fine on the first database
but not on the second database. And the only difference between the 2
DB is that the first database have the declaration of the foreign key
constraints between all tables, and for the second database I didn't
declare the foreign key constraints.

The problem seems to be related to the "left outer join" in the SQL
statement and to the use of 2 different alias for the same database
table. I dont understand why it could work when I declare the
constraints between table and not when I dont declare it. Is that
forbiden to use 2 alias for the same Table?


Here the 2 tables on wich I make the query and the relation between
them:

AstInstrument
| (1..1)
|
|
| (1..1)
AstInstrumentOSS


This is the query wich I have the problem when the foreign keys are not
declare. The problem is very odd, it jam the Sybase database. I need to
restart the Sybase database to close the query. It works well when the
FK are declared.


>>>>>
select AstInstrumentOss1.astInstrumentId as astInstr1_2_,
AstInstrumentOss1.astDataSource as astDataS2_2_2_,
AstInstrument1.astInstrumentId as astInstr1_0_,
AstInstrumentOss2.astInstrumentId as astInstr1_1_,
AstInstrumentOss2.astLastMaintDate as astLast11_2_1_

from dbo.AstInstrumentOss AstInstrumentOss1

left outer join dbo.AstInstrument AstInstrument1 on
AstInstrumentOss1.astInstrumentId=AstInstrument1.astInstrumentId
left outer join dbo.AstInstrumentOss AstInstrumentOss2 on
AstInstrument1.astInstrumentId=AstInstrumentOss2.astInstrumentId

where AstInstrumentOss1.astInstrumentId=15032
>>>>>

Any idea?

Thanks

Etienne
Montreal

.



Relevant Pages

  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)
  • Re: OT: SQL
    ... query processing. ... FROM Employees e, Employees m, Management mgt ... Manager and Employee Salaries. ... The scheme used does not model database files in general, ...
    (sci.logic)
  • Re: access 2003
    ... I removed the parameters from the form query source. ... boxes from the form header, events, code, etc and ran the form query source ... forms queries and the SQL because syntax of the SQL will change randomly. ... the Access 97 database, I wouldn't have thought any expressions would be ...
    (microsoft.public.access.conversion)
  • RE: Import external data - web query
    ... Your reply for my query is very extensive, this is for importing a file from ... The data source I want isn't listed in the Select Data Source dialog box. ... information used to connect to a database. ... Check your driver First, make sure you have the right ODBC driver (Open ...
    (microsoft.public.excel.misc)
  • Re: access 2003
    ... I removed the parameters from the form query source. ... synchronize combo boxes to the detail section or the parameter form query ... forms queries and the SQL because syntax of the SQL will change randomly. ... the Access 97 database, I wouldn't have thought any expressions would ...
    (microsoft.public.access.conversion)