[V4RB] Need a bit of help with Many to Many relationship

Kevin Windham kevo at gatorgraphics.com
Thu Feb 6 10:31:06 CST 2003


I am working on an app in which I have two tables related to each other 
by a third table which only has 2 object pointer fields. It is 
basically the same as the Has table in example 4 of the V4RB tutorial.

I am trying to wrap my brain around how to create the proper queries 
for these tables.

In the tutorial there is this example.

Now you can try a SQL query on both tables:
SELECT *
FROM Person, Has, Task
WHERE byte_fld < 10 AND status = 1 AND
person.id = has.person_ptr AND has.task_ptr = task.id
ORDER BY string_fld DESC

Again, with Valentina you can skip the specification of a LINK 
condition:
SELECT *
FROM Person, Has, Task
WHERE byte_fld < 10 AND status = 1
ORDER BY string_fld DESC

I have two basic questions that I can't seem to figure out.

1. If I simply want to get a list of all the RecIDs in one table 
related to a specific record in the other table, how would I write that 
query, and can it be written without the link conditions somehow or is 
that not possible in this case.

2. Somewhat related to the first question, how does Valentina know what 
the link conditions are? Is it from the location of the fields in the 
where clause? Also, when is it appropriate to leave off the table 
qualifier in an SQL expression. In the above to queries, I would 
normally write task.status instead of just status.

Thanks,
Kevin



More information about the Valentina mailing list