# Using Comparison Operators in Expressions - MapInfo_Pro - 2023

## MapInfo Pro Help

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapInfo Pro
Version
2023
Language
English
Product name
MapInfo Pro
Title
MapInfo Pro Help
First publish date
1985
ft:lastEdition
2023-09-12
ft:lastPublication
2023-09-12T16:39:16.995549

Use the Expression dialog box to formulate mathematical and alphanumeric expressions in several MapInfo Pro dialog boxes. Comparison operators are often used in creating expressions. The following chart shows the comparison operator symbols and a description.

Operators Description

=

"equals"

<>

"not equals"

>

"greater than"

<

"less than"

>=

"greater than or equal to"

<=

"less than or equal to"

## Numerical Comparison

Numerical comparisons are based on the numerical values of the expressions and numerical constants.

English: All rows where the household income is above \$65,000.

1. HH_INC>65000

Comment: Do not add the dollar sign or comma. MapInfo Pro does not know what to do with it and gives you an error message.

English: All rows where the median age is 42.

1. MED_AGE=42

Comment: This expression selects only those records where the median age is exactly 42. When your median age data contains a decimal portion (which is the case for MapInfo Pro-supplied demographic data) then it is unlikely that there are many regions with a median age of exactly 42.

The following expression gives you better results:

1. Round(MED_AGE, 1)=42

Comment: The function "round(somenumber, somenumber)" rounds the first number in the way specified by the second. In this example, the first number is the median age (MED_AGE) and the second is 1, indicating that median age is to be rounded to the nearest whole number.

English: All rows where the amount does not equal \$23,000.

1. AMOUNT<>23000

Comment: You might want to use the Round function, as in 10, if you are not concerned that the value be exactly 23000.

## String Comparison

String comparisons are based on the exact character content of the string. In this case ">" means "alphabetically greater than" (for example, comes after in the alphabet) and "<" means "alphabetically less than."

When typing a string into an expression, you should enclose it in quotes so that MapInfo Pro knows to treat it as a string, rather than treating it as a column name.

English: All rows where the vendor is Acme.

1. VENDOR="Acme"

Comment: Note that Acme is in quotes so that MapInfo Pro knows to treat it literally (as a character string) rather than to search for a column named Acme.

English: All rows where the vendor is not Acme.

1. VENDOR<>"Acme"

## Date Comparison

English: All entries received on October 9, 1991.

Note: Consider these conventions:
• The date is enclosed in quotes
• It is in the form: Month, Day, Year
• The numbers in the data are separated by a hyphen or a slash (/)
• Two characters were used for the year. You can also use four characters (1991)

English: All received after October 9, 1991.

Comment: This expression does not select those received on October 9, 1991. When you want them as well:

English: Records for all received before August.

Comment: This expression uses the Month function to extract the month in the date. It does not specify any particular year. When your database has records for several years, this expression does not pay attention to the particular year.

## Logical Comparison

English: All that have shipped.

1. Shipped

Comment: The column "Shipped" is a logical column. It contains "T" for true, or yes, and "F" for false, or no. When an order is shipped, it is marked "T". Otherwise, it is not shipped. For orders that are shipped, expression 28 evaluates to true. For orders not shipped it evaluates to false.

English: All that have not shipped.

1. Str\$(Shipped)="F"
2. Not Shipped