Convert foreign key in params to where clause