This example creates a Selective relationship between 2 tables.
FUNCTION Start
LOCAL oEng AS DaoDbEngine
LOCAL oDb AS DaoDatabase
LOCAL oOrders AS DaoQuery
LOCAL oDetails AS DaoQuery
LOCAL oProducts AS DaoQuery
Set color TO w+/b
cls
// Open the database.
oEng := DaoDbEngine{}
oDb := oEng:OpenDatabase("\VO2jet\Northwind.mdb",NIL,NIL,NIL)
// Open a recordset on Orders table.
// and also a recordset on the OrderDetails table
oOrders := DaoQuery{"Orders",DbOpenDynaSet,DbReadOnly,oDb}
oDetails := DaoQuery{"Order Details",DbOpenDynaSet,DbReadOnly,oDb}
oProducts := DaoQuery{"Products",DbOpenDynaSet,DbReadOnly,oDb }
oOrders:SetRelation(oDetails, #OrderId ,"OrderId")
oDetails:SetRelation(oProducts, #ProductId , "ProductID")
DO WHILE ! oOrders:Eof .and. oOrders:Recno < 5
? "Order: ",oOrders:FIELDGET(#orderId), oOrders:FIELDGET(#OrderDate)
DO WHILE ! oDetails:Eof
//oProducts:FindFirst("ProductId = " + Ntrim(oDetails:Fieldget(#ProductId)))
? "Detail:",oDetails:FIELDGET(#OrderId), oDetails:FIELDGET(#ProductId), oProducts:FIELDGET(#Productname)
oDetails:Skip(1)
ENDDO
oOrders:Skip(1)
ENDDO
oDb:Close()
wait