General X++ Development
How do I join two tables in an X++ select statement?
How do I join two tables in an X++ select statement?
1 answer
Write an answerAdd the second table with join and put the relationship in the where.
SalesTable salesTable;
CustTable custTable;
while select salesTable
join custTable
where custTable.AccountNum == salesTable.CustAccount
{
info(strFmt('%1 - %2', salesTable.SalesId, custTable.name()));
}If the tables can be joined directly, keep it in one query. Running another select inside the loop just creates extra database calls.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer