The where clause of the subquery could be empty and we should search for query inside joins. issue8394 review253951002