View Full Version : LEFT JOIN problem


MilanHa
10-02-2006, 08:07 AM
Hi
I have proplem with this sample query

SELECT * FROM sys LEFT JOIN [local] ON [sys].[PK_]=[local].[SYS_PK_]

In the MS Access it is going well but when i try to connect to database from my application through ODBC, and I run query driver returns
recordset with right records count but with EOF=BOF=TRUE

Error appears only when in the left table is record with no pair in the right table

table sys:

PK_;NAME
1;"Name1"
2;"Name2"
3;"Name3"

table local:

PK_;SYS_PK_,DESCR
1;1;"Descr1"
2;2;"Descr2"


Thanks

Milan

KeithG
10-02-2006, 08:45 AM
I believe both EOF and BOF are true beacuase you just opened the recordset and have not moved to a record yet.

MilanHa
10-03-2006, 07:50 AM
I think that EOF and BOF don't have to be TRUE (only if recordset is empty).
When I try move - the error is returned

*****
But now I have found some solution.

I' ve tried exclude local.PK_ from fields and it is functioning.

OK
SELECT sys.*,local.SYS_PK_,local.DESCR FROM sys LEFT JOIN local ON sys.PK_ = local.SYS_PK_;

FALSE
SELECT sys.*,local.SYS_PK_,local.DESCR ,local.PK_ FROM sys LEFT JOIN local ON sys.PK_ = local.SYS_PK_;

NULL value of autoincrement NUMBER is that problem, I think.
When I try to use PK_ from right table - that is problem.