I am using the MySQL Workbench 5.2.34 to write queries that will be used later on a php site. A particular query that returns a NULL value has me stumped (perhaps I have hit the limit of Red Bull and am missing something obvious):
SELECT sum(SalesAmount)
FROM HISTORY
WHERE PartNumber IN (SELECT PartNumber FROM MANIFEST_ITEMS WHERE manifestid = '905712');
When I run the subquery independently, I get the expected results:
SELECT PartNumber
FROM MANIFEST_ITEMS
WHERE manifestid = '905712';
When I run the outer query independently (with sample data that is returned by the subquery), I get the expected results:
SELECT sum(SalesAmount)
FROM HISTORY
WHERE PartNumber IN ('MC024LL/A','MC373LL/A','MC375LL/A','MC371LL/A');
I think the issue is that in the third example, I have escaped my return values, but when the subquery is returning these values, they are not escaped. If that is the case, is it possible to automagically escape these subquery return values?
Thank you!