Tech Tip: Query Method Comparators
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 15, 2024
Using the .query() method, the "=" and "==" operators are essentially the same. They retreive matching data and allow for use of the wildcard character "@". If the user wants to query using "@" as a normal character, "===" may be used. Both of these are not case sensitive .
For example, either of these lines would find all entries in "Contacts" with a "FirstName" starting with the letter A.
$selection:=ds.Contact.query("FirstName = :1"; "a@") |
$selection:=ds.Contact.query("FirstName == :1"; "A@") |
Whereas this line will only find someone with "A@" or "a@" set as the "FirstName".
$selection:=ds.Contact.query("FirstName === :1"; "A@") |
The operator "IS" works the same as the "===" operator. This line will give all the Contacts with the "FirstName" value "Alex" or "alex".
$selection:=ds.Contact.query("FirstName IS :1"; "Alex") |
The operator "IN" works similarly to the "=" or "==" except that it requires a collection to search through. It does support the wildcard character. This line will give all entries with a "FirstName" that begins with an A or B.
$selection:=ds.Contact.query("FirstName IN :1"; New collection("A@"; "B@")) |