KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Querying records with the literal "@" character
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: March 13, 2013

Using the QUERY command will use the "@" character as a wildcard. However, this is not always the desired behavior. In cases where a query should treat the "@" character as its literal character and not as a wildcard, the QUERY BY FORMULA command can be used. Below is an example.

Say there is a "Users" table with a "username" field containing three records with the following usernames:
- user@
- user1
- user2

Executing the following lines of code will return all three records in the selection:

$username:="user@"
QUERY([Users];[Users]username=$username)


However, using the command QUERY BY FORMULA as follows will return only the one record where the username is "user@":
$username:="user@"
QUERY BY FORMULA([Users];\
  
Generate digest([Users]username;MD5 Digest)=Generate digest($username;MD5 Digest))