General X++ Development

How do I use `exists join` in X++?

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

How do I use exists join in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Use exists join when the second table is only there to prove that a related record exists.

X++
CustTable  custTable;
SalesTable salesTable;

while select custTable
    exists join salesTable
        where salesTable.CustAccount == custTable.AccountNum
{
    info(custTable.AccountNum);
}

This returns customers that have at least one sales order. You are not using the joined SalesTable buffer for output, so there is no reason to do a normal join.