General X++ Development

How do I use multiple joins in an X++ select statement?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I use multiple joins in an X++ select statement?

SSunny Vasty75 reputation · answered Aug 13, 2026

Keep adding joins to the same select.

X++
SalesTable    salesTable;
CustTable     custTable;
DirPartyTable party;

while select salesTable
    join custTable
        where custTable.AccountNum == salesTable.CustAccount
    join party
        where party.RecId == custTable.Party
{
    info(strFmt('%1 - %2', salesTable.SalesId, party.Name));
}

If the relationship can be handled in one query, do that. Nested selects are usually just extra round trips to SQL.