acbugs
-
Posts
2 -
Joined
-
Last visited
Posts posted by acbugs
-
-
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!
Problem with JOIN and multiple comparisons
in PHP Coding Help
Posted
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')");