A code similar to mysql...for applying queries to 2 datasets