Solved

list data from 2 tables

Posted on 2008-10-10
4
238 Views
Last Modified: 2012-05-05
i am a novice to sql and oracle express edition i am learning . i need to display patient 's number(pno) , patient name(pname) and drug name (dname) they have been prescribed to .

i have tried: select pno, pname from patient but it is only for a single table drug name (dname) should be associated
hospital-data.doc
0
Comment
Question by:evry2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22689791
can you show the 2 tables full structure? and the column that is the foreign key?
usually, this should be a 3-tables design:

TABLE: patient
p_no
p_name
comments
...


TABLE: drug
d_no
d_name
comments
...

TABLE: prescription
p_id
p_no  => patient.p_no
d_no  => drug.d_no
date_start
date_end
comments
...

0
 

Author Comment

by:evry2004
ID: 22694759
tables are attached
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22694884
prescription = dose :)

this will be the base SQL...
you might need to add more conditions...
select *
  from patient p
  join dose 
    on dose.pno = p.pno 
  join drug d
    on d.dno = dose.dno

Open in new window

0
 

Author Closing Comment

by:evry2004
ID: 31505150
thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question