Skip to main content

Operators / Wildcards

SQL Arithmetic Operators

OperatorDescription
+Add
-Subtract
*Multiply
/Divide
%Modulo

SQL Bitwise Operators

OperatorDescription
&Bitwise AND
|Bitwise OR
^Bitwise exclusive OR

SQL Comparison Operators

OperatorDescription
=Equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
\, !=Not equal to
\Null safe equal=operator, but returns1rather thanNULLif both operands are NULL, and 0 rather than NULL if one operand is NULL.

SQL Compound Operators

OperatorDescription
+=Add equals
-=Subtract equals
*=Multiply equals
/=Divide equals
%=Modulo equals
&=Bitwise AND equals
^-=Bitwise exclusive equals
|*=Bitwise OR equals

SQL Logical Operators

OperatorDescription
ALLTRUE if all of the subquery values meet the condition
ANDTRUE if all the conditions separated by AND is TRUE
ANYTRUE if any of the subquery values meet the condition
BETWEENTRUE if the operand is within the range of comparisons
EXISTSTRUE if the subquery returns one or more records
INTRUE if the operand is equal to one of a list of expressions
LIKETRUE if the operand matches a pattern
NOTDisplays a record if the condition(s) is NOT TRUE
ORTRUE if any of the conditions separated by OR is TRUE
SOMETRUE if any of the subquery values meet the condition
-- ALL Operator
-- all countries whose area is greater than each area of each city from city table
SELECT * FROM country WHERE area > ALL (
SELECT area FROM city
);

-- ANY Operator
-- find trips to the cities which are cheaper than ANY hiking trip to the mountain with id 1
SELECT * FROM trip WHERE price < ANY (
SELECT price FROM hiking_trip WHERE mountain_id = 1
);

https://www.w3schools.com/sql/sql_operators.asp

Wildcard Characters in MS Access

SymbolDescriptionExample
*Represents zero or more charactersbl* finds bl, black, blue, and blob
?Represents a single characterh?t finds hot, hat, and hit
[]Represents any single character within the bracketsh[oa]t finds hot and hat, but not hit
!Represents any character not in the bracketsh[!oa]t finds hit, but not hot and hat
-Represents a range of charactersc[a-b]t finds cat and cbt
#Represents any single numeric character2#5 finds 205, 215, 225, 235, 245, 255, 265, 275, 285, and 295

Wildcard Characters in SQL Server

SymbolDescriptionExample
%Represents zero or more charactersbl% finds bl, black, blue, and blob
_Represents a single characterh_t finds hot, hat, and hit
[]Represents any single character within the bracketsh[oa]t finds hot and hat, but not hit
^Represents any character not in the bracketsh[^oa]t finds hit, but not hot and hat
-Represents a range of charactersc[a-b]t finds cat and cbt

https://www.w3schools.com/sql/sql_wildcards.asp