How to create a view in SQL based on multiple tables?
-
I'm working on a school assignment. Its basically a database on students. I have following two tables namely: EXAM_DETAILS and EXAM_APPEARS, The Fields for EXAM_DETAILS are (exam_code, total_marks, exam_date) The Fields for EXAM_APPEARS are(roll_no, exam_code, marks) Now, I've to create a view showing details of:-“roll_no, exam_name, marks, total_marks, exam_date”, for students having marks in the range 40 to 60. Can u please tell me how to create a view that comprises of fields from more than one table. A heart-full thanx +2points guaranteed!
-
Answer:
It will be something like this though I take no responsibility if there is an error in there. CREATE VIEW NEW_VIEW AS SELECT A.roll_no, exam_name, --Where does this even come from? A.marks, D.total_marks, D.exam_date FROM EXAM_APPEARS A JOIN EXAM_DETAILS D ON A.exam_code = D.exam_code WHERE A.marks >= 40 AND A.marks <= 60
James Hahn at Yahoo! Answers Visit the source
Other answers
You will want to use a JOIN to accomplish your task.
Related Q & A:
- How To Create A Profile In Facebook?Best solution by Yahoo! Answers
- How To Create A Forum?Best solution by Super User
- How to animate a View with Translate Animation in Android?Best solution by Stack Overflow
- How to create a Database in FoxPro and how to retrieve and sort it out?Best solution by Yahoo! Answers
- How to create a science-based monopoly?Best solution by forevergeek.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.