<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MySQL Archives - OptimumBrew Technology</title>
	<atom:link href="https://optimumbrew.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://optimumbrew.com/category/mysql/</link>
	<description></description>
	<lastBuildDate>Wed, 15 Jan 2025 10:55:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://optimumbrew.com/wp-content/uploads/2021/12/favicon.svg</url>
	<title>MySQL Archives - OptimumBrew Technology</title>
	<link>https://optimumbrew.com/category/mysql/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Streamline Database Operations with Our MySQL Cheat Sheet</title>
		<link>https://optimumbrew.com/streamline-database-operations-with-our-mysql-cheat-sheet/</link>
					<comments>https://optimumbrew.com/streamline-database-operations-with-our-mysql-cheat-sheet/#respond</comments>
		
		<dc:creator><![CDATA[Jaimisha Patel]]></dc:creator>
		<pubDate>Thu, 09 Nov 2023 08:58:36 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">https://optimumbrew.com/?p=32065</guid>

					<description><![CDATA[<p>A MySQL cheat sheet is a simple, user-friendly reference document containing essential basic functions and commands used in MySQL database management. It provides quick access to fundamental SQL queries for tasks like creating, reading, updating, and deleting data.</p>
<p>The post <a href="https://optimumbrew.com/streamline-database-operations-with-our-mysql-cheat-sheet/">Streamline Database Operations with Our MySQL Cheat Sheet</a> appeared first on <a href="https://optimumbrew.com">OptimumBrew Technology</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: 400;">In the world of database management, MySQL stands out as one of the most popular and powerful relational database systems. Whether you&#8217;re a seasoned database administrator or just starting your journey in the world of databases, having a reliable cheat sheet at your disposal can be invaluable. This comprehensive MySQL cheat sheet is designed to be your go-to resource for quickly accessing essential commands and tips to streamline your database operations.</span></p>
<p><span style="font-weight: 400;">Feel free to bookmark this page or share it with your peers. Dive in and make the most of this MySQL cheat sheet!</span></p>
<p><a href="https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3.png"><img fetchpriority="high" decoding="async" class="aligncenter wp-image-32082 size-full" src="https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3.png" alt="" width="2382" height="4562" srcset="https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3.png 2048w, https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3-157x300.png 157w, https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3-535x1024.png 535w, https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3-768x1471.png 768w, https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3-802x1536.png 802w, https://optimumbrew.com/wp-content/uploads/2023/11/mysql-cheat-sheet-Page-3-1069x2048.png 1069w" sizes="(max-width: 2382px) 100vw, 2382px" /></a></p>
<p><strong>Download Options:</strong></p>
<ul>
<li><a href="https://drive.google.com/file/d/1WNl68opwv_Annwd2YliJqm6AZVrXeQ2X/view?usp=sharing"><span style="font-weight: 400;">Download in PDF</span></a></li>
</ul>
<p>&nbsp;</p>
<h2>Table of Contents</h2>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">What is MySQL?</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Sample Data</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Query</span><span style="font-weight: 400;">ing tables</span>
<ul>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Filtering Data</span></li>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Filtering on numeric columns</span></li>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Filtering on text columns</span></li>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Filtering on multiple columns</span></li>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Filtering on missing data</span></li>
</ul>
</li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Aggregating Data</span>
<ul>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Simple aggregations</span></li>
<li style="font-weight: 400;" aria-level="2"><span style="font-weight: 400;">Grouping, filtering, and sorting</span></li>
</ul>
</li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">MySQL-Specific Syntax</span></li>
</ul>
<h2><b>What is MySQL?</b></h2>
<p><span style="font-weight: 400;">MySQL is an open-source relational database management system (RDBMS) known for its fast performance and reliability. Developed by Oracle Corporation, it&#8217;s widely used for web applications and online publishing.</span></p>
<h2><b>Sample Data</b></h2>
<p><span style="font-weight: 400;">The dataset contains details of the world&#8217;s highest valued media employees by gross sales. Each row contains one department, and the table is named </span><span style="font-weight: 400;">employees</span><span style="font-weight: 400;">.</span></p>
<h2><b>Querying tables</b></h2>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get all the columns from a table using </span><span style="font-weight: 400;">SELECT *</span></li>
</ul>
<p style="padding-left: 80px;"><span style="color: #008000;"><span style="font-weight: 400;">SELECT</span><span style="font-weight: 400; color: #000000;"> * </span><span style="font-weight: 400;">FROM</span></span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get a column from a table by name using </span><span style="font-weight: 400;">SELECT col</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get multiple columns from a table by name using </span><span style="font-weight: 400;">SELECT col1, col2</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Override column names with </span><span style="font-weight: 400;">SELECT col AS new_name</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span><span style="font-weight: 400; color: #008000;">AS</span><span style="font-weight: 400;"> creation_year </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Arrange the rows in ascending order of values in a column with </span><span style="font-weight: 400;">ORDER BY col</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">ORDER BY</span><span style="font-weight: 400;"> inception_year</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Arrange the rows in descending order of values in a column with </span><span style="font-weight: 400;">ORDER BY col DESC</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> incentive </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">ORDER BY</span><span style="font-weight: 400;"> incentive </span><span style="font-weight: 400; color: #008000;">DESC</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Limit the number of rows returned with </span><span style="font-weight: 400;">LIMIT n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> * </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">LIMIT </span><span style="font-weight: 400; color: #993300;">2</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get unique values with </span><span style="font-weight: 400;">SELECT DISTINCT</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT DISTINCT</span><span style="font-weight: 400;"> client_name </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<h2><b>Filtering Data</b></h2>
<h4><b>Filtering on numeric columns</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is greater than a value with </span><span style="font-weight: 400;">WHERE col &gt; n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &gt; </span><span style="font-weight: 400; color: #993300;">1928</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is greater than or equal to a value with </span><span style="font-weight: 400;">WHERE col &gt;= n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &gt;= </span><span style="font-weight: 400; color: #993300;">1928</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is less than a value with </span><span style="font-weight: 400;">WHERE col &lt; n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &lt; </span><span style="font-weight: 400; color: #993300;">1977</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is less than or equal to a value with </span><span style="font-weight: 400;">WHERE col &lt;= n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &lt;= </span><span style="font-weight: 400; color: #993300;">1977</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is equal to a value with </span><span style="font-weight: 400;">WHERE col = n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year = </span><span style="font-weight: 400; color: #993300;">1996</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is not equal to a value with </span><span style="font-weight: 400;">WHERE col &lt;&gt;</span><span style="font-weight: 400;"> n or </span><span style="font-weight: 400;">WHERE col != n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &lt;&gt; </span><span style="font-weight: 400; color: #993300;">1996</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where a number is between two values (inclusive) with </span><span style="font-weight: 400;">WHERE col BETWEEN m AND n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year <span style="color: #000000;">BETWEEN </span></span><span style="font-weight: 400; color: #993300;">1928</span><span style="font-weight: 400;"> AND </span><span style="font-weight: 400; color: #993300;">1977</span></p>
<h4><b>Filtering on text columns</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where text is equal to a value with </span><span style="font-weight: 400;">WHERE col = &#8216;x&#8217;</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> original_medium </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> original_medium = </span><span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">book</span>&#8216;</span><span style="font-weight: 400;"> </span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where text is one of several values with </span><span style="font-weight: 400;">WHERE col IN (&#8216;x&#8217;, &#8216;y&#8217;)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> original_medium </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> original_medium IN </span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">movie</span>&#8216;</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">video</span> <span style="color: #3366ff;">game</span>&#8216;</span><span style="font-weight: 400;">)</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where text contains specific letters with </span><span style="font-weight: 400;">WHERE col LIKE &#8216;%abc%&#8217;</span><span style="font-weight: 400;"> (% represents any characters)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> original_medium </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> original_medium LIKE </span><span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">%oo%</span>&#8216;</span></p>
<h4><b>Filtering on multiple columns</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the rows where one condition and another condition holds with </span><span style="font-weight: 400;">WHERE condn1 AND condn2</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> insentive </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &lt; </span><span style="font-weight: 400; color: #993300;">1950 </span><span style="font-weight: 400;">AND insentive &gt; </span><span style="font-weight: 400; color: #993300;">50</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the rows where one condition or another condition holds with </span><span style="font-weight: 400;">WHERE condn1 OR condn2</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> inception_year</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> insentive </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span> <span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> inception_year &lt; </span><span style="font-weight: 400; color: #993300;">1950 </span><span style="font-weight: 400;">OR insentive &gt; </span><span style="font-weight: 400; color: #993300;">50</span></p>
<h4><b>Filtering on missing data</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where values are missing with </span><span style="font-weight: 400;">WHERE col IS NULL</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> sales </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> sales IS </span><span style="font-weight: 400; color: #993300;">NULL</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where values are not missing with </span><span style="font-weight: 400;">WHERE col IS NOT NULL</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> department</span><span style="font-weight: 400;">,</span><span style="font-weight: 400;"> sales </span><span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> sales IS NOT </span><span style="font-weight: 400; color: #993300;">NULL</span></p>
<h2><b>Aggregating Data</b></h2>
<h4><b>Simple aggregations</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the total number of rows </span><span style="font-weight: 400;">SELECT COUNT(*)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT </span><span style="font-weight: 400; color: #3366ff;">COUNT</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">*</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the total value of a column with </span><span style="font-weight: 400;">SELECT SUM(col)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT </span><span style="font-weight: 400; color: #3366ff;">SUM</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">insentive</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the mean value of a column with </span><span style="font-weight: 400;">SELECT AVG(col)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT </span><span style="font-weight: 400; color: #3366ff;">AVG</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">insentive</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the mean value of a column with </span><span style="font-weight: 400;">SELECT AVG(col)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT </span><span style="font-weight: 400; color: #3366ff;">AVG</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">insentive</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the maximum value of a column with </span><span style="font-weight: 400;">SELECT MAX(col)</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT </span><span style="font-weight: 400; color: #3366ff;">MAX</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">insentive</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees</span></p>
<h4><b>Grouping, filtering, and sorting</b></h4>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get summaries grouped by values with </span><span style="font-weight: 400;">GROUP BY col</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> client_name</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400; color: #3366ff;">COUNT</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">*</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="color: #008000;"><span style="font-weight: 400;">GROUP</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> client_name</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get summaries grouped by values, in order of summaries with </span><span style="font-weight: 400;">GROUP BY col ORDER BY smmry DESC</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> original_medium</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400; color: #3366ff;">SUM</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">sales</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">AS</span><span style="font-weight: 400;"> total_products </span><span style="font-weight: 400; color: #008000;">FROM </span><span style="font-weight: 400;">employees </span> <span style="color: #008000;"><span style="font-weight: 400;">GROUP</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> original_medium </span><span style="color: #008000;"><span style="font-weight: 400;">ORDER</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> total_products </span><span style="font-weight: 400; color: #008000;">DESC</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get rows where values in a group meet a criterion with </span><span style="font-weight: 400;">GROUP BY col HAVING condn</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> original_medium</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400; color: #3366ff;">SUM</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">sales</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">AS</span><span style="font-weight: 400;"> total_products </span><span style="font-weight: 400; color: #008000;">FROM </span><span style="font-weight: 400;">employees </span><span style="color: #008000;"><span style="font-weight: 400;">GROUP</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> original_medium </span><span style="color: #008000;"><span style="font-weight: 400;">ORDER</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> total_products  </span><span style="color: #008000;"><span style="font-weight: 400;">DESC</span> <span style="font-weight: 400;">HAVING</span></span><span style="font-weight: 400;"> total_products &gt; </span><span style="font-weight: 400; color: #993300;">10</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Filter before and after grouping with </span><span style="font-weight: 400;">WHERE condn_before GROUP BY col HAVING condn_after</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> original_medium</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400; color: #3366ff;">SUM</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">sales</span><span style="font-weight: 400;">)</span> <span style="font-weight: 400; color: #008000;">AS</span><span style="font-weight: 400;"> total_products </span><span style="font-weight: 400; color: #008000;">FROM</span> employees <span style="font-weight: 400; color: #008000;">WHERE</span> client_name = &#8216;UG Tech Holdings&#8217; <span style="color: #008000;"><span style="font-weight: 400;">GROUP</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> original_medium </span> <span style="color: #008000;"><span style="font-weight: 400;">ORDER</span> <span style="font-weight: 400;">BY</span></span><span style="font-weight: 400;"> total_products </span><span style="font-weight: 400; color: #008000;">DESC </span><span style="font-weight: 400; color: #008000;">HAVING</span><span style="font-weight: 400;"> total_products &gt; </span><span style="font-weight: 400; color: #993300;">10</span></p>
<h2><b>MySQL-Specific Syntax</b></h2>
<p><span style="font-weight: 400;">Not all code works in every dialect of SQL. The following examples work in MySQL, but are not guaranteed to work in other dialects.</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Limit the number of rows returned, offset from the top with </span><span style="font-weight: 400;">LIMIT m, n</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> * </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span><span style="font-weight: 400; color: #008000;">LIMIT </span><span style="font-weight: 400; color: #993300;">2</span><span style="font-weight: 400;">,</span> <span style="font-weight: 400; color: #993300;">3</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">By default, MySQL uses case insensitive matching in WHERE clauses.</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> * </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span> <span style="font-weight: 400; color: #008000;">WHERE</span><span style="font-weight: 400;"> client_name = </span><span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">UG Tech Holdings</span>&#8216;</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">To get case-sensitive matching, use </span><span style="font-weight: 400;">WHERE BINARY condn</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> * </span> <span style="font-weight: 400; color: #008000;">FROM</span><span style="font-weight: 400;"> employees </span> <span style="font-weight: 400; color: #008000;">WHERE BINARY</span><span style="font-weight: 400;"> client_name = </span><span style="font-weight: 400;">&#8216;<span style="color: #3366ff;">UG Tech Holdings</span>&#8216;</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Get the current date with </span><span style="font-weight: 400;">CURDATE()</span><span style="font-weight: 400;"> and the current datetime with </span><span style="font-weight: 400;">NOW()</span><span style="font-weight: 400;"> or </span><span style="font-weight: 400;">CURTIME()</span></li>
</ul>
<p style="padding-left: 80px;"><span style="font-weight: 400; color: #008000;">SELECT</span><span style="font-weight: 400;"> NOW(), CURDATE(), CURTIME()</span></p>
<p><b>Conclusion</b></p>
<p><span style="font-weight: 400;">In conclusion, MySQL is a widely used and powerful relational database management system known for its performance and reliability. This comprehensive MySQL cheat sheet provides essential commands and tips for database administrators and beginners alike. It covers various aspects of MySQL usage, from querying and filtering data to aggregating and sorting information. Additionally, it offers insights into MySQL-specific syntax, ensuring you can leverage the full potential of this database system.</span></p>
<p>The post <a href="https://optimumbrew.com/streamline-database-operations-with-our-mysql-cheat-sheet/">Streamline Database Operations with Our MySQL Cheat Sheet</a> appeared first on <a href="https://optimumbrew.com">OptimumBrew Technology</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://optimumbrew.com/streamline-database-operations-with-our-mysql-cheat-sheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
