Ok, all you SQL and MySQL experts. I have a question.
I need an SQL command to display only the results that return a NULL value. I know I need to use a LEFT JOIN command, but I'm getting all the results, NULLS included.
This is the command I have:
SELECT FLNAME, CLTERM, CLYEAR
FROM tblFaculty F LEFT JOIN tblCLasses C
ON F.FNUM=C.FNUM
FLName appears in tblFaculty and CLTERM and CLYEAR are in tblClasses.
I need to display results where F.Num has no corresponding value to C.FNum. Any Ideas? I'm missing something in my command.
thanks
+ Reply to Thread
Results 1 to 8 of 8
-
TANSTAAFL
-
Originally Posted by Prot
SELECT FLNAME, CLTERM, CLYEAR
FROM tblFalculty F, tblClasses C
where F.FNUM NOT IN
(Select FNUM from tblClasses) -
Check your PM.
Try:
SELECT F.FLNAME, C.CLTERM, C.CLYEAR
FROM tblFaculty F, tblCLasses C
WHERE F.FNUM=C.FNUM(+) -
Originally Posted by tekkieman
This query is going to be a 1 to none, and I did not take notes like I should have. Poor me
Well, the assignment is not due until Wednesday, and I will see another student in the class in one of my other classes. Guess I could ask him. Otherwise I will just have to ask instructor tomorrow.
Thanks for the replies.TANSTAAFL -
I found the answer on my own. All I needed was an additional statement.
SELECT FLNAME, CLTERM, CLYEAR
FROM tblFaculty F LEFT JOIN tblCLasses C
ON F.FNUM=C.FNUM
WHERE CLTERM is NULLTANSTAAFL -
I would have suggested that, but for some reason I thought you had already put that in your original query. I could have sworn I saw that WHERE CLTERM is NULL line already.
-
SQL is at times quite counterintuitive, since it's kinda read "backwards".
-
Dammit!!! The one question I could've answered and I miss it! Stupid knowing SQL!
Similar Threads
-
Microsoft SQL Server need in Vegas Pro 11?
By videobread in forum EditingReplies: 5Last Post: 11th Dec 2011, 22:11 -
Microsoft SQL Server, can I uninstall it?
By alegator in forum ComputerReplies: 3Last Post: 27th Jun 2010, 23:14 -
How can I join 2 sup files?
By EC in forum SubtitleReplies: 3Last Post: 25th Mar 2010, 11:51 -
new chinese sql website attack has begun
By aedipuss in forum ComputerReplies: 4Last Post: 15th Nov 2008, 16:53 -
Anyone know SQL queries?
By sdsumike619 in forum ComputerReplies: 3Last Post: 16th Oct 2008, 20:37