SELECT * FROM ( SELECT ... FROM ... ) q1 INNER JOIN ( SELECT ... FROM ... ) q2 ON q1.colname = q2.colname