\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Gaston} \pdfinfo{ /Title (pseudo-sql.pdf) /Creator (Cheatography) /Author (Gaston) /Subject (PSEUDO-SQL Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{PSEUDO-SQL Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Gaston} via \textcolor{DarkBackground}{\uline{cheatography.com/24027/cs/47539/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Gaston \\ \uline{cheatography.com/gaston} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 2nd January, 2026.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format}} \tn % Row 0 \SetRowColor{LightBackground} General idea & PSEUDO-SQL (PQL in this context) is a formal data processing language with non-formal data definitions & \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} formal & In the scope of this language we speak of "formal" when the keywords and syntax is exactly defined like in a programming language or real SQL & \tn % Row Count 17 (+ 10) % Row 2 \SetRowColor{LightBackground} \seqsplit{non-formal} & In the scope of this document non-formal elements, if thosw elements are not, or not fully defined and are to be stated in such a wayx that they make sense in plain language. So we may for example reference a full-address in a statement where as in a real database this would be split into several fields & \tn % Row Count 38 (+ 21) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format (cont)}} \tn % Row 3 \SetRowColor{LightBackground} \seqsplit{Keywords} \& Syntax & The language keywords (i.e. language tokens) and syntax are formally defined. But informal statements may be introduced by the user & \tn % Row Count 9 (+ 9) % Row 4 \SetRowColor{white} Basic PQL \seqsplit{statment} & The basic PQL statement differs from the standard SQL in that the destination is usually only a name for the result of the statement. The destination and source may have the same name, stating that the source record set is to be updated. In general the result of this statement is a new destination record set which would override any existing one with same name & SELECT destination FROM source ... \tn % Row Count 34 (+ 25) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format (cont)}} \tn % Row 5 \SetRowColor{LightBackground} Record sets & A record set is a list of records which is not formally defined. I.e. it is not mandatory that all records explicitely have the same columns available (see Missing columns). & \tn % Row Count 12 (+ 12) % Row 6 \SetRowColor{white} Initial record set(s) & Initial record sets are those which are used as source without being created by any previous PQL statement. In most cases it will not be necessary to formally introduce these as they should be informally \seqsplit{comprehensible.} & \tn % Row Count 27 (+ 15) % Row 7 \SetRowColor{LightBackground} \seqsplit{Identifiers} & Identifiers are names which are composed of alphanumeric character, underscore and/or minus but no space. Identifiers shall also start with a letter or underscore & \tn % Row Count 38 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \seqsplit{Informal} columns & Column names should be informal, and thus meaning full by their name. Columns are virtual and can represent any simple or complex concept (like the \seqsplit{employee-office-number-and-address)} & \tn % Row Count 13 (+ 13) % Row 9 \SetRowColor{white} Formal columns & Sometimes informal column identifiers may get too cumbersome to describe its full usage and scope. In these cases columns may be formally defined using an informal description. The recordset name is optional in case the column is to be globally available & DEFINE {[}\textless{}recordset\textgreater{}.{]}\textless{}column\textgreater{} AS \textless{}desciption\textgreater{} \tn % Row Count 30 (+ 17) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format (cont)}} \tn % Row 10 \SetRowColor{LightBackground} & This definition simply reuses a previous column definition and may optionally alter its definition via another informal description & DEFINE \textless{}recordset\textgreater{}.\textless{}column\textgreater{} = {[}\textless{}recordset\textgreater{}{]}.column\textgreater{} BUT \textless{}description\textgreater{} \tn % Row Count 9 (+ 9) % Row 11 \SetRowColor{white} Missing columns & As described in the record sets topic, records in a record set are not expected to each have the same set of columns. This is handled by a set of formal rules below & \tn % Row Count 21 (+ 12) % Row 12 \SetRowColor{LightBackground} & RULE 1: tests & Missing columns being assumed empty they behave like empty columns in any test \tn % Row Count 26 (+ 5) % Row 13 \SetRowColor{white} & RULE 2: assignment & Any value assigned to an non-existent column virtually creates that column in the given record. This rule generally allows to add new columns to any recordsetz \tn % Row Count 36 (+ 10) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.596 cm} x{2.964 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{General format (cont)}} \tn % Row 14 \SetRowColor{LightBackground} WHERE \seqsplit{condition} & Just like in plain SQL, PSQ allows to filter records via the WHERE keyword. The conditions are PQL specific however & \tn % Row Count 8 (+ 8) % Row 15 \SetRowColor{white} JOINS & Joins being pure SQL database technical statments, they are not used in PQL. If at any time select data from several record sets are required as source, a record set should be previously created by a PQL statement making it easier comprehensible & \tn % Row Count 25 (+ 17) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Conditions}} \tn % Row 0 \SetRowColor{LightBackground} 'condition' or ('condition') & Informal conditions are to be written in single quotes. Additional parenthesis may be added for better readability where required \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} NOT | AND | OR & Boolean operators in order of precedence (highest to lowest) \tn % Row Count 9 (+ 3) % Row 2 \SetRowColor{LightBackground} ( condition ) & Conditions can be grouped in parenthesizes to manage proper precedence \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}