acbugs Posted March 11, 2014 Share Posted March 11, 2014 Hi all, I've been struggling with this bit of code for a while, and I need help! I have two tables, and I'm trying to do a LEFT OUTER JOIN where values found in the first table but not in the second table will be printed to the screen. However, I also need to compare some other submitted variables (year, outcomenumber, unitnumber) so that the result is narrowed down. This code is giving me the opposite of what I want, and I can't seem to tweak it to get the results I need. warehouselogin is a list of all instructors, and warehousedatains is a list of submitted data by instructors. I want to check to see which instructors have not submitted data for a certain year and outcome number and print those to the screen. $r = mysql_query("SELECT * FROM warehouselogin LEFT OUTER JOIN warehousedatains on warehouselogin.instructor_password = warehousedatains.instructor_password && warehousedatains.unitnumber='$unitnumber' && warehousedatains.year='$year' && warehousedatains.outcomenumber='$outcomenumbercheck' WHERE warehousedatains.instructor_password IS NOT NULL GROUP BY warehouselogin.InstructorName ASC"); Thanks so much for any suggestions! Quote Link to comment Share on other sites More sharing options...
Solution acbugs Posted March 11, 2014 Author Solution Share Posted March 11, 2014 To anyone else who needs help with a similar problem, this is the query I used to give me the results I needed in a PHP script. $r = mysql_query("SELECT * FROM warehouselogin WHERE unitnumber='$unitnumber' && warehouselogin.instructor_password NOT IN (SELECT warehousedatains.instructor_password FROM warehousedatains WHERE unitnumber='$unitnumber' && outcomenumber='$outcomenumbercheck')"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.