Using “Not Like” in X++ select statements

 If you want to use wild-cards in Ax, you can write a SQL statement with a LIKE keyword

SalesTable salestable;

select firstonly salestable
where salestable.salesId like '123*';

But if you want to use NOT LIKE you can do in 3 different ways :

SalesTable salestable;

select firstonly salestable
where !(salestable.salesId like '123*');
SalesTable salestable, salestableExists;

select firstonly salestable
    notExists join salestableExists
    where salestable.salesId == '123*';
Query query = new Query();
QueryRun queryRun;


query.addDataSource(tableNum(Salestable)).addRange(fieldNum(SalesTable, SalesId)).value('!123*');

queryRun = new QueryRun(query);
if(queryRun.next())
{
.....
}

Comments