support complex query in joins