I have been stuck at this problem for almost a week and may get the pink slip if I can't solve it soon. As such, I would appreciate any assistance.
The 'column2 = table2.column2' seems to be the culprit.
SELECT (SELECT column2
FROM (SELECT column3,
column2
FROM table2 AS table2Alias
WHERE column2 = table2.column2
GROUP BY column2 COLLATE utf8_bin, column3
ORDER BY COUNT(*),
column2 COLLATE utf8_bin) AS t
GROUP BY column3
ORDER BY COUNT(*),
column2 COLLATE utf8_bin
LIMIT 1) AS t2
FROM table2
WHERE column1 IS NULL
GROUP BY column2
EDIT: How can I move the nested nested subquery one or two levels outside so that it can access a column of the outermost table?
EDIT 2: The names of the columns have been changed for obvious reasons. I don't actually use 'file' or 'directory' in the actual code. The code has nothing to do with files or directories.
EDIT 3: I've changed the names to prevent confusion.