Re: HELP: SQL SELECT

From: Shawn Lavin <shawn_at_news.mdli.com>
Date: 1995/10/17
Message-ID: <4616qb$er7_at_colossus.holonet.net>#1/1


sl6gs_at_cc.usu.edu wrote:
: I have a table of patient code, every patient with a card_no(unique)
: but each card_no with multi DIAG_COD NO, I can not figure out
: how to find a patient with several DIAG_COD at same time, say
: I want to use SQL find all the patients with both DIAG_COD
: 621.100 and 303.500 or with 621.100 and 303.500 and 339.000
 

: sample table as following

what about :

select a.* from pt_code a,pt_code b where

  a.card_no = b.card_no and
  a.diag_code = 621.100 and
  b.diag_code = 303.500;

This is very basic SQL join of the table to itself. Depending upon the RDBMS and the indexes you might want to reorganize the query to improve performance, but the result is basically the same.

--
Shawn Lavin
(shawn_at_mdli.com)

As always, my opinions are my own
Received on Tue Oct 17 1995 - 00:00:00 CET

Original text of this message