{"id":7046,"date":"2024-02-22T00:00:00","date_gmt":"2024-02-22T05:00:00","guid":{"rendered":"https:\/\/www.sisense.com\/sql-symbol-cheatsheet\/"},"modified":"2024-10-11T08:32:32","modified_gmt":"2024-10-11T12:32:32","slug":"sql-symbol-cheatsheet","status":"publish","type":"post","link":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/","title":{"rendered":"SQL cheat sheet &#038; query syntax"},"content":{"rendered":"\r\n<p><em>SQL is one of the analyst\u2019s most powerful tools. In\u00a0<strong>SQL Superstar<\/strong>, we give you actionable advice to help you get the most out of this versatile language and create beautiful, effective queries.<\/em><\/p>\r\n\r\n\r\n\r\n<p>When you are new to programming in SQL, you will come across a lot of hard-to-search-for character operators. If you are prone to forgetting ~ is called <strong>tilde<\/strong>, are wondering why there are so many %s in your strings, or have a hard time googling what the <strong>(+)<\/strong> symbol in where users.group_id(+) = group.id, this guide is for you.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Comparison Operators<\/h2>\r\n\r\n\r\n\r\n<p>You are well acquainted with the equality and inequality operators for equals-to, less-than, and greater-than being =, &lt;, and &gt;, but you might not have seen all of the variants for specifying not-equals-to, not-less-than, and not-greater-than.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">!=<\/td>\r\n<td>Not equal to<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&lt;&gt;<\/td>\r\n<td>Not equal to<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">!&gt;<\/td>\r\n<td>Not greater than<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">!&lt;<\/td>\r\n<td>Not less than<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>While some databases like <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/language-elements\/not-less-than-transact-sql?view=sql-server-2017\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">sql-server support not less than<\/a> and not greater than, they do not support the analogous not-less-than-or-equal-to operator !&lt;=.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Unary and Bitwise Operators<\/h2>\r\n\r\n\r\n\r\n<p>When working with structured numbers, like IP addresses, it can be helpful to extract specific digits from the number using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bitwise_operation\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">bitwise operations<\/a>. Numbers are stored using binary, and you can think of the 1s being true and the 0s being false, and apply <a href=\"https:\/\/en.wikipedia.org\/wiki\/Boolean_algebra\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">boolean algebra<\/a> to manipulate the numbers.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&amp;<\/td>\r\n<td>Bitwise and<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">|<\/td>\r\n<td>Bitwise or<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">^<\/td>\r\n<td>Bitwise xor<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>There is an additional bitwise operator among the unary operators + and &#8211; for defining a positive or negative number. Bitwise not, ~, inverts each of the bits in your number.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">+<\/td>\r\n<td>Positive<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&#8211;<\/td>\r\n<td>Negative<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">~<\/td>\r\n<td>Bitwise not<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>Suppose you wanted to know if a number was even or odd. You could divide by two, take the modulo of two, or other arithmetic strategies, but it can be computationally faster to just look at the last bit. 505 &amp; 1 returns 1 whereas 168 &amp; 1 returns 0.<\/p>\r\n\r\n\r\n\r\n<p><strong><strong>Get SQL tips and tricks from our experts<\/strong>:<\/strong><\/p>\r\n\r\n\r\n\r\n<p><a class=\"action-btn \" href=\"https:\/\/www.sisense.com\/resources\/whitepapers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Read More<\/a><\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Arithmetic Operators<\/h2>\r\n\r\n\r\n\r\n<p>The arithmetic operators +, -, *, \/ for addition, subtraction, multiplication, and division are old friends, but you might not have encountered % before in an algebraic context. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Modulo_operation\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Modulo<\/a> divides its left side value by its right side value and returns the remainder. It\u2019s a companion operator for division, which returns the quotient.<\/p>\r\n\r\n\r\n\r\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Division_(mathematics)#Of_integers\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">integer division<\/a>, 9 \/ 2 = 4, to get the remainder you can use 9 % 2, which equals 1. The definition breaks down when working with negative numbers, but you will get an answer. For most SQL variants, an easy trick is it will inherit the sign of the left operator: 5 % 3 = 2 and 5 % -3 = 2, but -5 % 3 = -2 and -5 % -3 = -2.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">+<\/td>\r\n<td>Addition<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&#8211;<\/td>\r\n<td>Subtraction<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">*<\/td>\r\n<td>Multiplication<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">\/<\/td>\r\n<td>Division<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">%<\/td>\r\n<td>Modulo<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Assignment Operators<\/h2>\r\n\r\n\r\n\r\n<p>Some SL languages, like SQL Server, use = for assignment, while others like MySQL and Postgres use :=.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">=<\/td>\r\n<td>Assignment<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">:=<\/td>\r\n<td>Assignment<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>In SQL Server, you can use most of the bitwise or arithmetic operators to assign the computed value back into the left operand in a compound assignment. For example:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>SET @x1 = @x1 + 7;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>can be re-written as:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>SET @x1 += 7;<\/code><\/pre>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">+=<\/td>\r\n<td>Addition<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">-=<\/td>\r\n<td>Subtraction<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">*=<\/td>\r\n<td>Multiplication<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">\/=<\/td>\r\n<td>Division<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">%=<\/td>\r\n<td>Modulo<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&amp;=<\/td>\r\n<td>Bitwise and<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">|=<\/td>\r\n<td>Bitwise or<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">^=<\/td>\r\n<td>Bitwise xor<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Bitshifting<\/h2>\r\n\r\n\r\n\r\n<p>Another way to manipulate bits in SQL is using arithmetic <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bitwise_operation#Bit_shifts\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">bitshifting<\/a>. This operation \u201cmoves\u201d the bits in your number either left or right and fills in the new values with 0s. Bitshifting left is an easy way to multiply by powers of 2, and Bitshifting right divides by powers of 2. For example, 5 &lt;&lt; 2 equals 20. You move the bits 101 to 10100, which is the same result as multiplying by four.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&lt;&lt;<\/td>\r\n<td>Bitshift left<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&gt;&gt;<\/td>\r\n<td>Bitshift right<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>Numbers in SQL are limited to a fixed number of bits. An integer type, for example, will only have 32 bits, and if you bitshift a bit past the 32nd value, it is dropped from the number. Generally, if you bitshift by a number larger than 32, it uses the modulo: 7 &lt;&lt; 34 behaves like 7 &lt;&lt; 2.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Boolean logic<\/h2>\r\n\r\n\r\n\r\n<p>MySQL let\u2019s you substitute the character equivalents for and, or, and not in conditionals. You can replace<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>where user_id &lt; 10 and not group_id = 3<\/code><\/pre>\r\n\r\n\r\n\r\n<p>with<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>where user_id &lt; 10 &amp;&amp; ! group_id = 3<\/code><\/pre>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&amp;&amp;<\/td>\r\n<td>Logical and<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">||<\/td>\r\n<td>Logical or<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">!<\/td>\r\n<td>Logical not<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">String comparisons and manipulation<\/h2>\r\n\r\n\r\n\r\n<p>Working with strings can be unfamiliar whether you are new to programming or just new to SQL. Some SQL variants use the familiar + to concatenate strings, while others like MySQL use ||. When comparing strings using the like operator, % and _ act as wildcard match characters. For example, \u201cData\u201d matches D_t_ and %at%, while only the latter would match Data Teams. You can read a more in-depth introduction to strings <a href=\"\/blog\/string-parsing-in-sql\/\">here<\/a>.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">+<\/td>\r\n<td>Concatenation<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">||<\/td>\r\n<td>Concatenation<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">+=<\/td>\r\n<td>Concatenate and assign<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">%<\/td>\r\n<td>Match 0 or more wildcard<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">_<\/td>\r\n<td>Match exactly 1 wildcard<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">[]<\/td>\r\n<td>Escape special characters<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>There is an additional difference between strings quoted using a single quote mark (&#8216;) and a double quote (&#8220;). String literals are in \u2018single quotes\u2019 and \u201cdouble quotes\u201d denote identifiers, like table and column names.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Regular Expressions<\/h2>\r\n\r\n\r\n\r\n<p>Regular expressions are filled with esoteric characters, featuring special uses for a wide range of characters, including ? for optional matching, {2} for repetition, and enclosing ranges of characters in brackets: [A-Za-z0-9].<\/p>\r\n\r\n\r\n\r\n<p>For help deciphering the &#8216;.*([0-9]+)[ _-]?ye?a?rs( old)?&#8217; regular expression in SQL, check out this blog post.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Count<\/h2>\r\n\r\n\r\n\r\n<p>You may see both count(1) and count(*) in queries. They are interchangeable and both count the number of rows being selected.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">(*)<\/td>\r\n<td>Count rows per group<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">(1)<\/td>\r\n<td>Count rows per group<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>You may run into the occasional case where the count is being applied to a specific table \u2014 in these cases it counts the fields, not the rows in the table. We recommend you pick one and stick with it \u2014 there is no semantic or performance difference between the two formats. Note that the two counts here will return different quantities.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>select \r\n    count(*)\r\n    , count(groups.*) \r\nfrom \r\n  users \r\n  left join groups \r\n    on users.group_id = groups.id<\/code><\/pre>\r\n\r\n\r\n\r\n<p><strong>Type Conversion<\/strong><\/p>\r\n\r\n\r\n\r\n<p>In addition to using cast, you can use :: to cast a value to a specific type.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>select cast('2016-12-25' as date) as christmas<\/code><\/pre>\r\n\r\n\r\n\r\n<p>becomes<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>select '2016-12-25'::date as christmas<\/code><\/pre>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">::<\/td>\r\n<td>Type conversion<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p><strong>Postgres Json<\/strong><\/p>\r\n\r\n\r\n\r\n<p>Postgres has great <a href=\"https:\/\/www.postgresql.org\/docs\/9.4\/functions-json.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">support for json types<\/a>, including a slew of character operators to extract data out of a json blob.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">-&gt;<\/td>\r\n<td>Get json element<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">-&gt;&gt;<\/td>\r\n<td>Get json element as text<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">#&gt;<\/td>\r\n<td>Get element by path<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">#&gt;&gt;<\/td>\r\n<td>Get element by path as text<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">@&gt;<\/td>\r\n<td>Contains<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&lt;@<\/td>\r\n<td>Contains<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">?<\/td>\r\n<td>String exists<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">?|<\/td>\r\n<td>Any string exists<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">?&amp;<\/td>\r\n<td>All strings exist<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Local and Global variables<\/h2>\r\n\r\n\r\n\r\n<p>When defining variables in MySQL, they may be prefixed with @ or @@. A single @ lets a user-defined variable persist beyond the query that defined the variables, and @@ is a reference to global state, such as @@global.port.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">@<\/td>\r\n<td>User session variable<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">@@<\/td>\r\n<td>System variable<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>Oracle uses @ for running scripts. You can check out more <a href=\"https:\/\/docs.oracle.com\/cd\/B19306_01\/server.102\/b14357\/ch12003.htm\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">here<\/a>.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Comments<\/h2>\r\n\r\n\r\n\r\n<p>You can use comments to include text that won\u2019t get evaluated as part of your sql query. The standard set of comments tokens are &#8211;, \/*, *\/, and MySQL additionally uses # for inline comments.<\/p>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">&#8212;<\/td>\r\n<td>Inline comment<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">#<\/td>\r\n<td>Inline comment<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">\/*<\/td>\r\n<td>Block comment<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">*\/<\/td>\r\n<td>Block comment<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Oracle outer join<\/h2>\r\n\r\n\r\n\r\n<p>A legacy operator for older Oracle databases is the use of (+) to support outer joins.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>select *\r\nfrom users, groups\r\nwhere users.group_id(+) = groups.id<\/code><\/pre>\r\n\r\n\r\n\r\n<p>behaves similarly to<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>select *\r\nfrom users outer join groups\r\non users.group_id(+) = groups.id<\/code><\/pre>\r\n\r\n\r\n\r\n<div class=\"table-responsive\">\r\n<figure class=\"wp-block-table table table-bordered\">\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%;\"><strong>Symbol<\/strong><\/td>\r\n<td><strong>Operation<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%;\">(+)<\/td>\r\n<td>Outer join<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>It largely behaves the same as outer join, but there are some exceptions you can check out in <a href=\"https:\/\/docs.oracle.com\/cd\/B28359_01\/server.111\/b28286\/queries006.htm\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Oracle\u2019s language reference<\/a>.<\/p>\r\n\r\n\r\n\r\n<p><strong>Get SQL tips and tricks from our experts<\/strong>:<\/p>\r\n\r\n\r\n\r\n<p><a class=\"action-btn \" href=\"https:\/\/www.sisense.com\/resources\/whitepapers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Read More<\/a><\/p>\r\n\r\n\r\n\r\n<p><em><strong>Chris Meier<\/strong> is a Manager of Analytics Engineering for Sisense and boasts 8 years in the data and analytics field, having worked at Ernst &amp; Young and Soldsie. He\u2019s passionate about building modern data stacks that unlock transformational insights for businesses.<\/em><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>When you are new to programming in SQL, you will come across a lot of hard-to-search-for character operators. This guide will make your life much simpler!<\/p>\n","protected":false},"author":4,"featured_media":7233,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[44],"tags":[472],"application":[10],"buyer-role":[],"buyer-stage":[],"department":[6],"industry":[],"topic":[73],"class_list":["post-7046","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-talk","tag-data-team","application-cloud-data-teams","department-it","topic-sql-superstar"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v23.5 (Yoast SEO v23.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL Cheat Sheet and Query Syntax| Sisense<\/title>\n<meta name=\"description\" content=\"If you are new to SQL programming, here is a handy reference guide for character operators, syntax, and more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL cheat sheet &amp; query syntax\" \/>\n<meta property=\"og:description\" content=\"When you are new to programming in SQL, you will come across a lot of hard-to-search-for character operators. This guide will make your life much simpler!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\" \/>\n<meta property=\"og:site_name\" content=\"Sisense\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-22T05:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-11T12:32:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/yoast-cheat-blog-min.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sisense Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/yoast-cheat-blog-min.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@sisense\" \/>\n<meta name=\"twitter:site\" content=\"@sisense\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sisense Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\"},\"author\":{\"name\":\"Sisense Team\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115\"},\"headline\":\"SQL cheat sheet &#038; query syntax\",\"datePublished\":\"2024-02-22T05:00:00+00:00\",\"dateModified\":\"2024-10-11T12:32:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\"},\"wordCount\":1231,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.sisense.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg\",\"keywords\":[\"data team\"],\"articleSection\":[\"Tech Talk\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\",\"url\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\",\"name\":\"SQL Cheat Sheet and Query Syntax| Sisense\",\"isPartOf\":{\"@id\":\"https:\/\/www.sisense.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg\",\"datePublished\":\"2024-02-22T05:00:00+00:00\",\"dateModified\":\"2024-10-11T12:32:32+00:00\",\"description\":\"If you are new to SQL programming, here is a handy reference guide for character operators, syntax, and more.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage\",\"url\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg\",\"contentUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg\",\"width\":1200,\"height\":628,\"caption\":\"featured cheat blog min\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sisense.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL cheat sheet &#038; query syntax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sisense.com\/#website\",\"url\":\"https:\/\/www.sisense.com\/\",\"name\":\"Sisense\",\"description\":\"Build your business with anywhere-analytics\",\"publisher\":{\"@id\":\"https:\/\/www.sisense.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sisense.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.sisense.com\/#organization\",\"name\":\"Sisense\",\"url\":\"https:\/\/www.sisense.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg\",\"contentUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg\",\"width\":1200,\"height\":600,\"caption\":\"Sisense\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/sisense\",\"https:\/\/www.linkedin.com\/company\/sisense\",\"https:\/\/github.com\/sisense\/\"],\"description\":\"Sisense accelerates product innovation through AI\/ML capabilities. Our global analytics platform lets customers drive better, faster decisions for their business and end users.\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115\",\"name\":\"Sisense Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g\",\"caption\":\"Sisense Team\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Cheat Sheet and Query Syntax| Sisense","description":"If you are new to SQL programming, here is a handy reference guide for character operators, syntax, and more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/","og_locale":"en_US","og_type":"article","og_title":"SQL cheat sheet & query syntax","og_description":"When you are new to programming in SQL, you will come across a lot of hard-to-search-for character operators. This guide will make your life much simpler!","og_url":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/","og_site_name":"Sisense","article_published_time":"2024-02-22T05:00:00+00:00","article_modified_time":"2024-10-11T12:32:32+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/yoast-cheat-blog-min.jpg","type":"image\/jpeg"}],"author":"Sisense Team","twitter_card":"summary_large_image","twitter_image":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/yoast-cheat-blog-min.jpg","twitter_creator":"@sisense","twitter_site":"@sisense","twitter_misc":{"Written by":"Sisense Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#article","isPartOf":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/"},"author":{"name":"Sisense Team","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115"},"headline":"SQL cheat sheet &#038; query syntax","datePublished":"2024-02-22T05:00:00+00:00","dateModified":"2024-10-11T12:32:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/"},"wordCount":1231,"commentCount":0,"publisher":{"@id":"https:\/\/www.sisense.com\/#organization"},"image":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg","keywords":["data team"],"articleSection":["Tech Talk"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/","url":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/","name":"SQL Cheat Sheet and Query Syntax| Sisense","isPartOf":{"@id":"https:\/\/www.sisense.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage"},"image":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg","datePublished":"2024-02-22T05:00:00+00:00","dateModified":"2024-10-11T12:32:32+00:00","description":"If you are new to SQL programming, here is a handy reference guide for character operators, syntax, and more.","breadcrumb":{"@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#primaryimage","url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg","contentUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2020\/01\/10161850\/featured-cheat-blog-min.jpg","width":1200,"height":628,"caption":"featured cheat blog min"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sisense.com\/blog\/sql-symbol-cheatsheet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sisense.com\/"},{"@type":"ListItem","position":2,"name":"SQL cheat sheet &#038; query syntax"}]},{"@type":"WebSite","@id":"https:\/\/www.sisense.com\/#website","url":"https:\/\/www.sisense.com\/","name":"Sisense","description":"Build your business with anywhere-analytics","publisher":{"@id":"https:\/\/www.sisense.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sisense.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sisense.com\/#organization","name":"Sisense","url":"https:\/\/www.sisense.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg","contentUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg","width":1200,"height":600,"caption":"Sisense"},"image":{"@id":"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/sisense","https:\/\/www.linkedin.com\/company\/sisense","https:\/\/github.com\/sisense\/"],"description":"Sisense accelerates product innovation through AI\/ML capabilities. Our global analytics platform lets customers drive better, faster decisions for their business and end users."},{"@type":"Person","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115","name":"Sisense Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g","caption":"Sisense Team"}}]}},"_links":{"self":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/7046"}],"collection":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/comments?post=7046"}],"version-history":[{"count":1,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/7046\/revisions"}],"predecessor-version":[{"id":22797,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/7046\/revisions\/22797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/media\/7233"}],"wp:attachment":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/media?parent=7046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/categories?post=7046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/tags?post=7046"},{"taxonomy":"application","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/application?post=7046"},{"taxonomy":"buyer-role","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/buyer-role?post=7046"},{"taxonomy":"buyer-stage","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/buyer-stage?post=7046"},{"taxonomy":"department","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/department?post=7046"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/industry?post=7046"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/topic?post=7046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}