Sometimes we have to get rows from one table based on the list of value form other tables. We use in statement queries. For example I have to display only those customers which have at least one sales order in sales table. In this scenario we have to use in statement. But there is no in statement queries in dynamics Ax, We achieve this functionality with Exist join. Consider following code which result only Customer form Custtable who have entries in SalesTable.
query = new Query();
CustomerDataSource = query.addDataSource(tableNum(CustTable ));
SalesDataSource = CustomerDataSource.addDataSource(tableNum(SalesTable ));
fieldNum(SalesTable , CustAccount ));
queryrun = new QueryRun(query);
custtable = queryRun.get(tablenum(CustTable ));