\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{mr.freelancer} \pdfinfo{ /Title (mysql.pdf) /Creator (Cheatography) /Author (mr.freelancer) /Subject (MYSQL 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}{1826A3} \definecolor{LightBackground}{HTML}{F0F1F9} \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{MYSQL Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{mr.freelancer} via \textcolor{DarkBackground}{\uline{cheatography.com/201646/cs/42703/}}} \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}mr.freelancer \\ \uline{cheatography.com/mr-freelancer} \\ \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 5th April, 2024.\\ 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*}{3} \begin{tabularx}{5.377cm}{x{3.18528 cm} x{1.79172 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{CRUD commande BDD}} \tn % Row 0 \SetRowColor{LightBackground} \textasciicircum{}SHOW nomDeLaBase \textasciicircum{} & Voir la BDD \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textasciicircum{}USE nomDeLaBase\textasciicircum{} & Utilisé une BDD \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \textasciicircum{}CREATE DATABASE nomDeLaBase \textasciicircum{} & Créer une BDD \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \textasciicircum{}DROP DATABASE ma\_base\textasciicircum{} & Supprimer une BDD \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Ajout d'une colonne à une table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ALTER TABLE nom\_table \newline % Row Count 1 (+ 1) ADD nom\_colonne type\_donnees% Row Count 2 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{EX : ALTER TABLE utilisateur \newline ADD adresse\_rue VARCHAR(255)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Supprimer une colonne d'une table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ALTER TABLE nom\_table \newline % Row Count 1 (+ 1) DROP nom\_colonne% Row Count 2 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{EX: ALTER TABLE animal \newline DROP adresse\_rue} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Renommer une colonne d'une table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ALTER TABLE nom\_table \newline % Row Count 1 (+ 1) CHANGE colonne\_ancien\_nom colonne\_nouveau\_nom type\_donnees% Row Count 3 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{ALTER TABLE `animal` \newline CHANGE `image` `image` DECIMAL(255) NOT NULL;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Règle et convention}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SQL exécute les actions de cette façon : \newline % Row Count 1 (+ 1) FROM \newline % Row Count 2 (+ 1) WHERE \newline % Row Count 3 (+ 1) SELECT \newline % Row Count 4 (+ 1) Le noms des tables doivent être en minuscules et au singulier. \newline % Row Count 6 (+ 2) Toutes les commandes sql sont en majuscule \newline % Row Count 7 (+ 1) Bonnes pratiques \newline % Row Count 8 (+ 1) Utilisez des identifiants et noms cohérents et descriptifs. \newline % Row Count 10 (+ 2) Faites un usage judicieux de l'espace et de l'indentation afin de faciliter la lecture du code. \newline % Row Count 12 (+ 2) Utilisez la norme ISO 8601 pour les informations temporelles \seqsplit{(YYYY-MM-DDTHH:MM:SS.SSSSS).} \newline % Row Count 14 (+ 2) Essayez de n'utiliser que des fonctions SQL standard au lieu des fonctions spécifiques à chaque SGBD pour des raisons de portabilité. \newline % Row Count 17 (+ 3) Gardez le code court et évitez les redondances comme les parenthèses ou guillemets superflus, ou encore les clauses WHERE qui peuvent être dérivées. \newline % Row Count 21 (+ 4) Commentez le code SQL lorsque c'est nécessaire. Utilisez le style de commentaires du langage C, en ouvrant avec /{\emph{ et fermant avec }}/ là où c'est possible, autrement débutez les commentaires avec -{}- et faites-les suivre par une nouvelle ligne.% Row Count 27 (+ 6) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Having}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT colonne1, SUM(colonne2) \newline % Row Count 1 (+ 1) FROM nom\_table \newline % Row Count 2 (+ 1) GROUP BY colonne1 \newline % Row Count 3 (+ 1) HAVING fonction(colonne2) operateur valeur \newline % Row Count 4 (+ 1) La condition HAVING en SQL est presque similaire à WHERE à la seule différence \newline % Row Count 6 (+ 2) que HAVING permet de filtrer en utilisant des fonctions telles que SUM(), COUNT(), \newline % Row Count 8 (+ 2) AVG(), MIN() ou MAX().% Row Count 9 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT client, SUM(tarif) \newline FROM achat \newline GROUP BY client \newline HAVING SUM(tarif) \textgreater{} 40} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Jointure}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT * \newline % Row Count 1 (+ 1) FROM table1 \newline % Row Count 2 (+ 1) INNER JOIN table2 ON table1.id = table2.fk\_id \newline % Row Count 3 (+ 1) OU \newline % Row Count 4 (+ 1) SELECT * \newline % Row Count 5 (+ 1) FROM table1 \newline % Row Count 6 (+ 1) INNER JOIN table2 \newline % Row Count 7 (+ 1) WHERE table1.id = table2.fk\_id% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{FILTRE ORDRE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT colonne1, colonne2 \newline % Row Count 1 (+ 1) FROM table \newline % Row Count 2 (+ 1) ORDER BY colonne1 \newline % Row Count 3 (+ 1) SELECT colonne1, colonne2, colonne3 \newline % Row Count 4 (+ 1) FROM table \newline % Row Count 5 (+ 1) ORDER BY colonne1 DESC, colonne2 ASC \newline % Row Count 6 (+ 1) Par défaut les résultats sont classés par ordre ascendant% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT {\emph{ \newline FROM utilisateur \newline ORDER BY nom \newline \newline SELECT }} \newline FROM utilisateur \newline ORDER BY nom, date\_inscription DESC} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Créer une table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{CREATE TABLE nomDeLaTable ( \newline % Row Count 1 (+ 1) nomDuChamp TYPE options , \newline % Row Count 2 (+ 1) nomDuChamp TYPE options \newline % Row Count 3 (+ 1) ); \newline % Row Count 4 (+ 1) typeS : VARCHAR(nbCaractère) \newline % Row Count 5 (+ 1) FLOAT \newline % Row Count 6 (+ 1) INTEGER \newline % Row Count 7 (+ 1) BOOLEAN \newline % Row Count 8 (+ 1) LONGTEXT \newline % Row Count 9 (+ 1) options: \newline % Row Count 10 (+ 1) DEFAULT \{valeur\} \newline % Row Count 11 (+ 1) NOT NULL \newline % Row Count 12 (+ 1) NULL \newline % Row Count 13 (+ 1) PRIMARY KEY \newline % Row Count 14 (+ 1) AUTO\_INCREMENT% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{CREATE TABLE `animal` ( \newline `id` int(11) NOT NULL, \newline `nom` varchar(255) NOT NULL, \newline `description` longtext DEFAULT NULL, \newline `image` varchar(255) NOT NULL, \newline `poids` int(11) NOT NULL, \newline `dangereux` tinyint(1) NOT NULL, \newline `famille\_id` int(11) NOT NULL \newline )} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{GROUP BY}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT colonne1, fonction(colonne2) \newline % Row Count 1 (+ 1) FROM table \newline % Row Count 2 (+ 1) GROUP BY colonne1 \newline % Row Count 3 (+ 1) SELECT client, SUM(tarif) \newline % Row Count 4 (+ 1) FROM achat \newline % Row Count 5 (+ 1) GROUP BY client \newline % Row Count 6 (+ 1) La manière simple de comprendre le GROUP BY c'est tout simplement d'assimiler qu'il va \newline % Row Count 8 (+ 2) éviter de présenter plusieurs fois les mêmes lignes. C'est une méthode pour éviter les doublons% Row Count 11 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Filtre Caractère}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT * \newline % Row Count 1 (+ 1) FROM client \newline % Row Count 2 (+ 1) WHERE ville LIKE 'N\%' \newline % Row Count 3 (+ 1) LIKE '\%a' : le caractère "\%" est un caractère joker qui remplace tous les autres caractères. \newline % Row Count 6 (+ 3) Ainsi, ce modèle permet de rechercher toutes les chaines de caractère qui se termine par un "a". \newline % Row Count 9 (+ 3) LIKE 'a\%' : ce modèle permet de rechercher toutes les lignes de "colonne" qui commence par un "a".% Row Count 12 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{LIKE '\%a\%' : ce modèle est utilisé pour rechercher tous les enregistrement qui utilisent le caractère \newline "a". \newline \newline LIKE 'pa\%on' : ce modèle permet de rechercher les chaines qui commence par "pa" et qui se terminent \newline par "on", comme "pantalon" ou "pardon". \newline \newline LIKE 'a\_c' : peu utilisé, le caractère "\_" (underscore) peut être remplacé par n'importe quel caractère,} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Modifier des données}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Modifier une ligne : \newline % Row Count 1 (+ 1) UPDATE table \newline % Row Count 2 (+ 1) SET colonne\_1 = 'valeur 1', colonne\_2 = 'valeur 2', colonne\_3 = 'valeur 3' \newline % Row Count 4 (+ 2) WHERE condition \newline % Row Count 5 (+ 1) Modifier toutes les lignes : \newline % Row Count 6 (+ 1) UPDATE table \newline % Row Count 7 (+ 1) SET colonne = 'valeur'% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Modifier une ligne : \newline UPDATE client \newline SET rue = '49 Rue Ameline', \newline ville = \seqsplit{'Saint-Eustache-la-Forêt'}, \newline code\_postal = '76210' \newline WHERE id = 2 \newline \newline Modifier toutes les lignes : \newline UPDATE client \newline SET pays = 'FRANCE'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{LIMITE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT * \newline % Row Count 1 (+ 1) FROM table \newline % Row Count 2 (+ 1) LIMIT 10 \newline % Row Count 3 (+ 1) Cette requête permet de récupérer seulement les 10 premiers résultats d'une table.% Row Count 5 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT * \newline FROM table \newline LIMIT 5, 10; \newline \newline Cette requête retourne les enregistrements 6 à 15 d'une table. \newline Le premier nombre est l'OFFSET tandis que le suivant est la limite.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Comparaison}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{= Égale \newline % Row Count 1 (+ 1) \textless{}\textgreater{} Pas égale \newline % Row Count 2 (+ 1) != Pas égale \newline % Row Count 3 (+ 1) \textgreater{} Supérieur à \newline % Row Count 4 (+ 1) \textless{} Inférieur à \newline % Row Count 5 (+ 1) \textgreater{}= Supérieur ou égale à \newline % Row Count 6 (+ 1) \textless{}= Inférieur ou égale à \newline % Row Count 7 (+ 1) IN Liste de plusieurs valeurs possibles \newline % Row Count 8 (+ 1) BETWEEN Valeur comprise dans un intervalle donné (utile pour les nombres ou dates) \newline % Row Count 10 (+ 2) LIKE Recherche en spécifiant le début, milieu ou fin d'un mot. \newline % Row Count 12 (+ 2) IS NULL Valeur est nulle \newline % Row Count 13 (+ 1) IS NOT NULL Valeur n'est pas nulle \newline % Row Count 14 (+ 1) NOT EXISTS contraire% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Alias}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT column\_name AS alias\_name \newline % Row Count 1 (+ 1) FROM table\_name; \newline % Row Count 2 (+ 1) SELECT column\_name(s) \newline % Row Count 3 (+ 1) FROM table\_name AS alias\_name;% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Alias}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT column\_name AS alias\_name \newline % Row Count 1 (+ 1) FROM table\_name; \newline % Row Count 2 (+ 1) SELECT column\_name(s) \newline % Row Count 3 (+ 1) FROM table\_name AS alias\_name;% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Supprimer des données}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Supprimer une ligne \newline % Row Count 1 (+ 1) DELETE FROM `table` \newline % Row Count 2 (+ 1) WHERE condition \newline % Row Count 3 (+ 1) {\bf{EX :}} \newline % Row Count 4 (+ 1) DELETE FROM `utilisateur` \newline % Row Count 5 (+ 1) WHERE `id` = 1% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Supprimer toutes les données d'une table \newline DELETE FROM `nomTable` \newline \newline EX: DELETE FROM `utilisateur`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Sélectionné des données}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{SELECT `nomColonne`, `nomColonne` FROM nomDeLaTable ;% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT 'id', nom FROM animal} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{AGREGA}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{AVG()}}pour calculer la moyenne d'un set de valeur. Permet de connaître le prix du panier moyen pour de chaque client \newline % Row Count 3 (+ 3) {\bf{COUNT()}} pour compter le nombre de lignes concernées. Permet de savoir combien d'achats a été effectué par chaque client \newline % Row Count 6 (+ 3) {\bf{MAX() }}pour récupérer la plus haute valeur. Pratique pour savoir l'achat le plus cher \newline % Row Count 8 (+ 2) {\bf{MIN() }}pour récupérer la plus petite valeur. Utile par exemple pour connaître la date du premier achat d'un client \newline % Row Count 11 (+ 3) {\bf{SUM()}} pour calculer la somme de plusieurs lignes. Permet par exemple de connaître le total de tous les achats d'un client% Row Count 14 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Créer des données}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{INSERT INTO nomDeLaTable \newline % Row Count 1 (+ 1) (\textbackslash{}`colonne1\textbackslash{}`,\textbackslash{}`colonne2\textbackslash{}`,\textbackslash{}`colonne3\textbackslash{}`) \newline % Row Count 2 (+ 1) VALUES \newline % Row Count 3 (+ 1) (valeur1, valeur2, valeur3,); \newline % Row Count 4 (+ 1) attention si la vateur de de type texte mettre des guillemets. \newline % Row Count 6 (+ 2) pour les booleans mettre en majuscule.% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{INSERT INTO \textbackslash{}`animal\textbackslash{}` (\textbackslash{}`id\textbackslash{}`, \textbackslash{}`nom\textbackslash{}`, \textbackslash{}`description\textbackslash{}`, \textbackslash{}`image\textbackslash{}`, \textbackslash{}`poids\textbackslash{}`, \textbackslash{}`dangereux\textbackslash{}`, \textbackslash{}`famille\_id\textbackslash{}`) \newline VALUES \newline (36, 'Chien', 'Un animal domestique', 'chien.png', 10, 0, 13), \newline (39, 'Crocodile', 'Un animal très dangereux', 'croco.png', 500, 1, 14), \newline (40, 'Requin', 'Un animal marin très dangereux', 'requin.png', 800, 1, 15);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}