Re: Join multiple tables
Posted in 1994
In article <36unoj$rea@emory.mathcs.emory.edu>, JBTaylor@lanmail.rmc.com
("J. B. Taylor") wrote:
Sorry if this is not what you are asking but I read your article only partly.
Your problem is with your OR statenment. If you read your query it
actually says give me * where cont_id = container_id OR cont2_id =
container_id. The OR means that you will get everything where cont2_id =
container_id REGARDLESS of your first search criteria.
Try using parenthesis
where (manifest.manifest_id = $mani_id
and cont1_id = container_id
and container.manifest_id = $mani_id)
or
(cont2_id = container_id
and container.manifest_id = $mani_id)
hope this helps,
tdenbow@mathworks.com
> Example:
>
> In ACE report entering mani_id
>
> select manifest.manifest_id, cont1_id, cont2_id, cont3_id,
> cont4_id, container_id
> from manifest, container
> where manifest.manifest_id = $mani_id
> and cont1_id = container_id
> and container.manifest_id = $mani_id>
> This works fine for the first container but when I add -
>
> or cont2_id = container_id
> and container.manifest_id = $mani_id
>
> I get every container in the container table in my report. Also using the
> history table in the scheme of things causes even more problems. I have
> also tried using a query only on the manifest and a sub query in the where
> section with basically the same results. Can't see how a UNION claues
> would help.
>
>
> -------------------- ***** JBT ***** ------------------
>
>
> J. B. Taylor (jbtaylor@lanmail.rmc.com)
> Reynolds Metals Company
> Manufacturing Technology Laboratory
> 3326 East 2nd Street
> Muscle Shoals, AL 35661-1258
> FAX: 205-386-9656
> Voice: 205-386-9658
>
> -------------------------------------------------------