Question on expression format

Which is correct? PI_NO is a REF to to a table where PI_NO is the key with a number type. I know that is not the best to use for a key but the admin will always control this and it will only be changed at the data source.

OR([PI_NO]=1,[PI_NO]=2,[PI_NO]=3,[PI_NO]=4)

OR([PI_NO]=“1”,[PI_NO]=“2”,[PI_NO]=“3”,[PI_NO]=“4”)

Are they interchangeable? Are “” only needed if the data type was text?

Strictly speaking, within expressions, quotes are needed only to ensure the value isn’t misinterpreted as a keyword or special character, so 1 and "1" should be equivalent. To ensure textual values are always interpreted as such, I strongly recommend always quoting textual values. Likewise, temporal values contain special characters that would be misinterpreted, so should also be quoted. Numeric values are unlikely to be misinterpreted, so I don’t recommend quotes for them. Essentially, any raw value that isn’t numeric should be quoted.

2 Likes

Oh, and more efficient:

IN([PI_NO], {1, 2, 3, 4})
2 Likes

As @Steve already stated.

I never put quotes around my numerical values. Unless I explicitly am making them a part of some other text.

2 Likes

Great. Thanks for all the info.

1 Like