I shot a training video today while I was answering a SQL Join question on Yahoo Answers.
During the video, I construct the database, tables, and example data.
Then I tried to run the current query to see what error I get. Finally, I work through the issue and fix the join.
Here is the video:
If you couldn-t see the question well in the video, here is a reprint.
**Database SQL query issues?
*I have developed the database with the following tables:
**STUDENT
S_ID PRIMARY KEY
S_FNAME
S_LNAME
S_ADDRESS
S_CITY
S_STATE
S_ZIPCODE
S_PHONE
**SCHOLARSHIPS
S_ID PRIMARY KEY FOREIGN KEY REFERENCES STUDENT
SC_MAJOR
SC_ACADEMIC
SC_ATHLETIC ***
GPA
S_ID PRIMARY KEY FOREIGN KEY REFERENCES STUDENT
G_GPA
G_CLASS /(4 is for Seniors)/
I then inputted data and did the following SQL query:
**SELECT S_ID, S_LNAME, S_FNAME, S_ADDRESS, S_CITY, S_STATE, S_ZIPCODE, S_PHONE
FROM STUDENT
WHERE GPA.G_CLASS = 4
ORDER BY S_LNAME, S_FNAME;
**I get the following error:
The data content could not be loaded. Column not found: GPA.G_CLASS.
Please assist with any tutoring or assisting. Thank you.
My answer is to put in the inner join condition.
Here is the final query:
SELECT STUDENT.S_ID, S_LNAME, S_FNAME, S_ADDRESS, S_CITY, S_STATE, S_ZIPCODE, S_PHONE
FROM STUDENT inner join GPA on STUDENT.S_ID=GPA.S_ID
WHERE GPA.G_CLASS = 4
ORDER BY S_LNAME, S_FNAME;
I am attaching the script to create and populate the tables and the Microsoft Excel file so you can see how I create my INSERT statements.
SqlTrainingOnlineUniversityDB.zip
Let me know if you have any questions or comments by posting them below.