Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

sql

I am using the following statmement to retreive information. Lopdept only
contains dept information so I can not join on lopagnam. i get the right
dept record but the wrong agency record. I have tried several different thihngs
and have had no such luck. hoping someone could tell me what I am doing wrong.
If I remove the dept record from the sql it works fine.

Select dpttot.agency,dpttot.dpt,dpttot.mdfclose,dpttot.eafclose,dpttot.rraclose,dpttot.dropclose, lopdept.dptname,lopagnam.cityname;
from dpttot inner join lopdept join lopagnam on lopagnam.citynum=dpttot.agency
on lopdept.dept=dpttot.dpt;
Where dpttot.agency = 1007;
[667 byte] By [jarrett] at [2007-11-10 12:50:12]
# 1 Re: sql
Hi Jarrett,

First off, "nested" joins have never been as easy for me to work with as
sequential joins. What happens if you write your joins like this:

...
from dpttot ;
inner join lopdept on lopdept.dept = dpttot.dpt;
join lopagnam on lopagnam.citynum = dpttot.agency ;
...

Also, your join from dpttot to jopagnam - do you mean to have a left, right,
or full or inner join?

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org, www.cindywinegarden.com

"jarrett" <jcrudisill@yahoo.com> wrote in message
news:3f1418b5$1@tnews.web.dev-archive.com...
>
> I am using the following statmement to retreive information. Lopdept only
> contains dept information so I can not join on lopagnam. i get the right
> dept record but the wrong agency record. I have tried several different
thihngs
> and have had no such luck. hoping someone could tell me what I am doing
wrong.
> If I remove the dept record from the sql it works fine.
>
> Select
dpttot.agency,dpttot.dpt,dpttot.mdfclose,dpttot.eafclose,dpttot.rraclose,dpt
tot.dropclose,lopdept.dptname,lopagnam.cityname;
> from dpttot inner join lopdept join lopagnam on
lopagnam.citynum=dpttot.agency
> on lopdept.dept=dpttot.dpt;
> Where dpttot.agency = 1007;
>
Cindy Winegarden at 2007-11-11 23:50:38 >