web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to query equivalent of sql 'or' on different field

(0) ShareShare
ReportReport
Posted on by 1,559

Hi Friends,

I need to filter datasource using equivalent of sql 'or' keyword on different field.

like this: where table.field 1 = 1 or table.field2 = 2, or table.field3 = 3.

How can I do it in query?

Many thanks,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Hi Ganriver,

    please check this article, it will contain the information that you are looking for: msdn.microsoft.com/.../aa893981.aspx

  • Verified answer
    Catalyst619 Profile Picture
    355 on at

    Use || for the OR operator. 

    Use == for the comparison.

    select * from table where table.field == 1 || table.field == 2;

  • Ganriver1 Profile Picture
    1,559 on at

    Thanks, Nikolaos,

    I want to create a query object, then use it as datasource, can I do that?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Are you talking about form data sources?

    If you already have a form, and a data source, you can manipulate the query of that data source in x++.

  • Ganriver1 Profile Picture
    1,559 on at

    I mean to create a query in AOT, then use it as form data source.

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    You can create a query in AOT and use it as a form data source.

    However you can't create an "OR" range for different fields in the AOT query directly. Instead you have to apply these ranges during runtime in x++.

  • Verified answer
    Douglas Noel Profile Picture
    3,905 on at

    Hi,

    search for QueryRangeExpessions. The only chance to get an or condition between different fields in a query.

    there is a lot of stuff

    msdn.microsoft.com/.../aa893981.aspx

    Regards Douglas

  • Ganriver1 Profile Picture
    1,559 on at

    Thanks a lot, Guys.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans