Solved

list data from 2 tables

Posted on 2008-10-10
4
204 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 142

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 142

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
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.​
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now