Friday, March 9, 2012

Problem joining 2 Views

Hi guys,

I detected a strange behaviour when doing an inner join of two views.

There is table_Objects, table_Contracts and view_Objects, View_Contracts.

Table_Objects: ID, Price
View_Objects: Select * from Table_Objects Where Price > 10

Table_Contracts: ID, Year
View_Contracts: Select c.ID, c.Year
From Table_Contracts c Join View_Objects o on c.id=o.id

Quiete simple so far, but it doesn't work. Imagine Object with id 3 that is shown in View_Objects and Table_Contracts but not shown in View_Contracts. How is that possible?

EDIT: Sometimes its shown, sometimes not
Thx for your reply!Is Table_Contracts.ID a primary key or a foreign key to Table_Objects?|||Table_Contract's PK is (ID,Year)
Table_Object's PK is (ID)
There is a FK from Table_Contract(ID) to Table_Objects(ID)|||Oh, just realized that I'm joining a view and a table and not 2 views.

No comments:

Post a Comment