Solved

list data from 2 tables

Posted on 2008-10-10
4
229 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
  • 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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…

828 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