Send Gnumed-devel mailing list submissions to
address@hidden
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.gnu.org/mailman/listinfo/gnumed-devel
or, via email, send a message with subject or body 'help' to
address@hidden
You can reach the person managing the list at
address@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gnumed-devel digest..."
Today's Topics:
1. need SQL help (Karsten Hilbert)
----------------------------------------------------------------------
Date: Fri, 2 May 2003 17:03:10 +0200
From: Karsten Hilbert <address@hidden>
To: GNUmed list <address@hidden>
Subject: [Gnumed-devel] need SQL help
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Precedence: list
Message: 1
Horst, Ian, others,
I am trying to set up a view that displays the allergies per
patient. Problem being that in the allergy table the
id_comment is a foreign key into clin_narrative which can be
NULL if no comment is recorded. I can't figure out how to
select the rows I need !
select a.substance, cn.value
from
allergy a, clin_narrative cn
where
a.id_comment=cn.id;
This does not work because a.id_comment can be NULL.
select a.substance, cn.value
from
allergy a, clin_narrative cn
where
a.id_comment in (cn.id, NULL);
does not work either although it seems intuitive.
Any suggestions ?
For the full SQL definitions see server/sql/gmclinical.sql and
gmClinicalViews.sql.
Karsten