MariaDB Operators


Objectives

  • MariaDB Arithmetic Operators

  • MariaDB Comparison Operators

  • MariaDB Logical Operators


MariaDB Arithmetic Operators

Operator Description Example

+

Add

SELECT 6 + 6;

-

Subtract

SELECT 18 - 6;

*

Multiply

SELECT 3 * 4;

/

Divide

SELECT 24 / 2;

%

Modulo

SELECT 92 % 16;


MariaDB Comparison Operators

Operator Description Example

=

Equal to

SELECT * FROM person WHERE age = 20;

>

Greater than

SELECT * FROM person WHERE age > 20;

<

Less than

SELECT * FROM person WHERE income < 300;

>=

Greater than or equal to

SELECT * FROM person WHERE income >= 500;

<=

Less than or equal to

SELECT * FROM person WHERE income <= 500;

<>

Not equal to

SELECT * FROM person WHERE income <> 600;


MariaDB Logical Operators

AND

  • Description : TRUE if all the conditions separated by AND is TRUE

  • Example :

SELECT * FROM person WHERE age > 18 AND income < 300;


OR

  • Description : TRUE if any of the conditions separated by OR is TRUE

  • Example :

SELECT * FROM person WHERE age > 18 OR income < 300;


NOT

  • Description : Displays a record if the condition(s) is NOT TRUE

  • Example :

SELECT * FROM person WHERE NOT last_name = 'Doe';


BETWEEN

  • Description : TRUE if the operand is within the range of comparisons

  • Example :

SELECT * FROM person WHERE income BETWEEN 100 AND 300;


IN

  • Description : TRUE if the operand is equal to one of a list of expressions

  • Example :

SELECT * FROM person WHERE income IN (100, 150, 200, 250);


LIKE

  • Description : TRUE if the operand matches a pattern

  • Example :

SELECT * FROM person WHERE first_name LIKE "%n%";


MariaDB Operators Video tutorial