Re: SQL-Question: Error 393
Posted in 1997
Jonathan Leffler wrote:
> SELECT team.druck,
> nverteil.folge,
> nverteil.tage,
> team.bezeich tbezeich,
> klinik.bezeich kbezeich,
> ort.bezeich obezeich,
> personal.vollname,
> team.zahl
> FROM team , OUTER nverteil, personal, OUTER klinik, ort
> WHERE team.druck BETWEEN 0 AND 249
> AND team.teamnr = nverteil.teamnr
> AND nverteil.persnr = personal.persnr
> AND nverteil.teamnr = ort.teamnr[1]
> AND nverteil.teamnr = klinik.teamnr[1,3]
> AND nverteil.woche = "29.09.1997"
> ORDER BY druck, kbezeich, folge
> The problem join is the one between nverteil.teamnr and klinik.teamnr.
> These tables are both tagged with the OUTER keyword and cannot therefore
> be joined to each other.
> You should probably use "team.teamnr = klinik.teamnr".
Yes, that suggestion was correct! I did so and the query ran fine.
But why does the join between "nverteil" and "ort" work? Isn't their
relationship identical to "nverteil" and "klinik"?
I'll have to refine the query some more to get the desired results,
but that's a different problem...
> I think the subscripting on klinik.teamnr is unnecessary since the
> klinik table only holds the first three characters of the teamnr.
> You might need to use subscripting on team.teamnr to cut that down to
> 3 characters.
You are correct, of course! In the "original" query, I had done the
subscripting correct, but when I reformatted it for better readability
in my posting, I put the subscripts on the wrong field. Thanks for
your attention.
Regards, Richard
--
+--------------------------+------------------------------------------+
| Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de |
| EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3413 |
| Klinikum Grosshadern | FAX : +49-89-7095-8886 |
| 81366 Munich, Germany | |
+--------------------------+------------------------------------------+