Statement1 - Place a breakpoint on that line. Step through the code, when that breakpoint hits, press F10. Then look at the value of 'sql' and try running that against your database to see if it's a valid query or what's different about it from what you generated

Statement2 - We are not psychic, so "Problem with Join" does not actually help us in any way to understand your problem.