{"id":21064,"date":"2025-04-04T07:53:33","date_gmt":"2025-04-04T07:53:33","guid":{"rendered":"https:\/\/www.pickl.ai\/blog\/?p=21064"},"modified":"2025-07-24T16:19:31","modified_gmt":"2025-07-24T10:49:31","slug":"sql-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/","title":{"rendered":"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries"},"content":{"rendered":"\n<p><strong>Summary: <\/strong>The SQL Cheat Sheet provides a handy reference for mastering SQL commands. It covers database creation, querying data using SELECT and WHERE, joins, data manipulation with INSERT and UPDATE, and advanced operations like transactions and constraints. Perfect for developers and analysts to streamline database tasks efficiently.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Introduction\" >Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Tabular_Representation_of_SQL_Cheat_Sheet\" >Tabular Representation of SQL Cheat Sheet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Create_a_Database_in_SQL\" >Create a Database in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Creating_Data_in_SQL\" >Creating Data in SQL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Creating_Tables_CREATE_TABLE\" >Creating Tables (CREATE TABLE)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Inserting_Data_INSERT_INTO\" >Inserting Data (INSERT INTO)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#ReadingQuerying_Data_in_SQL\" >Reading\/Querying Data in SQL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Retrieve_all_columns\" >Retrieve all columns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Retrieve_specific_columns\" >Retrieve specific columns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Using_Aliases_AS\" >Using Aliases (AS)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#UpdatingManipulating_Data_in_SQL\" >Updating\/Manipulating Data in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Deleting_Data_in_SQL\" >Deleting Data in SQL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Deleting_Rows_DELETE_FROM\" >Deleting Rows (DELETE FROM)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Deleting_All_Rows_TRUNCATE_TABLE\" >Deleting All Rows (TRUNCATE TABLE)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Deleting_Tables_DROP_TABLE\" >Deleting Tables (DROP TABLE)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Deleting_Databases_DROP_DATABASE\" >Deleting Databases (DROP DATABASE)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Filtering_Data_in_SQL_WHERE\" >Filtering Data in SQL (WHERE)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Logical_Operators_AND_OR_NOT\" >Logical Operators (AND, OR, NOT)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Other_Useful_Filtering_Keywords\" >Other Useful Filtering Keywords<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#SQL_Operators\" >SQL Operators<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Aggregating_Data_in_SQL\" >Aggregating Data in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Grouping_Results_GROUP_BY\" >Grouping Results (GROUP BY)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Filtering_Groups_HAVING\" >Filtering Groups (HAVING)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Constraints_in_SQL\" >Constraints in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Joins_in_SQL\" >Joins in SQL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#INNER_JOIN\" >INNER JOIN<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#LEFT_JOIN_or_LEFT_OUTER_JOIN\" >LEFT JOIN (or LEFT OUTER JOIN)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#RIGHT_JOIN_or_RIGHT_OUTER_JOIN\" >RIGHT JOIN (or RIGHT OUTER JOIN)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#FULL_OUTER_JOIN\" >FULL OUTER JOIN<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#CROSS_JOIN\" >CROSS JOIN<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#SQL_Functions\" >SQL Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Subqueries_in_SQL\" >Subqueries in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Views_in_SQL\" >Views in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Indexes_in_SQL\" >Indexes in SQL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Trade-offs\" >Trade-offs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Dropping_an_Index\" >Dropping an Index<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-37\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Transactions_in_SQL\" >Transactions in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-38\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Advanced_Mixed_Data_in_SQL_CASE_Statement\" >Advanced Mixed Data in SQL (CASE Statement)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-39\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Common_Table_Expressions_CTEs\" >Common Table Expressions (CTEs)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-40\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-41\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Frequently_Asked_Questions\" >Frequently Asked Questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-42\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#What_Is_an_SQL_Cheat_Sheet\" >What Is an SQL Cheat Sheet?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-43\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#What_are_the_Essential_SQL_Commands_Covered_in_A_Cheat_Sheet\" >What are the Essential SQL Commands Covered in A Cheat Sheet?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-44\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#How_Can_an_SQL_Cheat_Sheet_Help_Beginners\" >How Can an SQL Cheat Sheet Help Beginners?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-45\" href=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#Can_I_Create_My_Own_SQL_Cheat_Sheet\" >Can I Create My Own SQL Cheat Sheet?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 id=\"introduction\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction\"><\/span><strong>Introduction<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In today&#8217;s data-driven world, the ability to interact with databases is no longer a niche skill\u2014it&#8217;s a fundamental requirement for developers, analysts, <a href=\"https:\/\/www.pickl.ai\/blog\/cheat-sheets-for-data-scientists\/\">data scientists<\/a>, and even marketers. At the heart of database interaction lies <a href=\"https:\/\/www.pickl.ai\/blog\/foreign-key-in-sql\/\">SQL (Structured Query Language)<\/a>, the standard language for managing and manipulating data stored in relational database management systems (RDBMS).<\/p>\n\n\n\n<p>Whether you&#8217;re just starting your journey with databases or you&#8217;re a seasoned professional looking for a quick refresher, having a handy reference guide is invaluable.&nbsp;<\/p>\n\n\n\n<p>This SQL cheat sheet aims to be that guide, covering the essential commands and concepts you need to effectively work with databases. We&#8217;ll walk through everything from creating your first database to executing complex queries and managing data integrity.<\/p>\n\n\n\n<p><strong><em>Let&#8217;s dive in!<\/em><\/strong><\/p>\n\n\n\n<p>SQL, pronounced &#8220;sequel&#8221; or simply &#8220;S-Q-L,&#8221; is the lingua franca of relational <a href=\"https:\/\/www.pickl.ai\/blog\/structure-of-database-management-system\/\">databases<\/a>. Developed in the early 1970s, it allows users to perform various operations like creating, reading, updating, and deleting (CRUD) data.&nbsp;<\/p>\n\n\n\n<p>Popular database systems like <a href=\"https:\/\/www.pickl.ai\/blog\/difference-between-sql-and-mysql\/\">MySQL<\/a>, PostgreSQL, SQL Server, Oracle, and SQLite all use SQL, although minor syntax variations (often called &#8220;flavours&#8221;) exist between them.<\/p>\n\n\n\n<p><strong>Key Takeaways<\/strong><\/p>\n\n\n\n<p>This cheat sheet is structured logically, following the typical lifecycle of data interaction:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setting up the database environment.<\/li>\n\n\n\n<li>Populating it with data.<\/li>\n\n\n\n<li>Querying and<a href=\"https:\/\/www.pickl.ai\/blog\/information-retrieval-in-nlp\/\"> retrieving information.<\/a><\/li>\n\n\n\n<li>Modifying existing data.<\/li>\n\n\n\n<li>Removing data.<\/li>\n\n\n\n<li>Advanced techniques for complex tasks.<\/li>\n<\/ul>\n\n\n\n<p>Keep this guide bookmarked \u2013 it&#8217;s designed to be your go-to reference for everyday SQL tasks.<\/p>\n\n\n\n<h2 id=\"tabular-representation-of-sql-cheat-sheet\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Tabular_Representation_of_SQL_Cheat_Sheet\"><\/span><strong>Tabular Representation of SQL Cheat Sheet<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcakajB2jSK-Y0X824qa7SkoVwksRCfEEFiObuuZwHM0Q9hnJIuF6VZ2Lis1lQQNOFJloX5x7pHPzb_dQ0CRxWJMNxo-6QdwwAcSnY9bjSVcJO5UzV7EZvm-t-UtIRz3c1aqikadIF5fK3zTtP8Bg?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"create-a-database-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_Database_in_SQL\"><\/span><strong>Create a Database in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before you can store data, you need a container for it \u2013 a database. The command is straightforward:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfveqfU1kA-Qc90bUolfOaA7iClVJtXBwbeTmvqpFCNaQ0mKPSZQR4OhAZmftWsDjPpD2M3Yj-L-qEIHsf_4WV62FxYoUx7pXBG3EQZGa89mg3SuBrRc6a8wbmRqicTbQXNIL39BLNYzMckNrI0MmM?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>CREATE DATABASE<\/strong>: The SQL statement to create a new database.<\/li>\n\n\n\n<li><strong>database_name<\/strong>: Replace this with the desired name for your database (e.g., company_db, blog_platform).<\/li>\n<\/ul>\n\n\n\n<p><strong>Note:<\/strong> Depending on your SQL client or environment, you might need specific permissions to create databases. Some systems may automatically switch you to use the newly created database, while others require an explicit command like USE database_name; (common in <a href=\"https:\/\/www.pickl.ai\/blog\/introduction-to-mysql\/\">MySQL<\/a> and SQL Server).<\/p>\n\n\n\n<h2 id=\"creating-data-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_Data_in_SQL\"><\/span><strong>Creating Data in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Once you have a database, you need structure (tables) and content (rows\/records).<\/p>\n\n\n\n<h3 id=\"creating-tables-create-table\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_Tables_CREATE_TABLE\"><\/span><strong>Creating Tables (CREATE TABLE)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Tables organize data into rows and columns. Each column has a name and a data type (e.g., INT for integers, VARCHAR(n) for variable-length strings, DATE for dates).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfndls9wNOiTLPpwXFiPsOscvd-MjArxfaC_EUA7Mnc58cSSTSFZRJP87eEWDMZIv8fr8weOzo_ssriJbSpS7iD4uKNh501O2LVBr8aFQ-TdwGCFgikxDL5gSz1NYsyPx76tejYLIP6ZSAB4vGQTQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>CREATE TABLE<\/strong>: The statement to define a new table.<\/li>\n\n\n\n<li><strong>table_name<\/strong>: The name of your table (e.g., employees, products).<\/li>\n\n\n\n<li><strong>column1, column2&#8230;<\/strong>: Names for the columns in your table.<\/li>\n\n\n\n<li><strong>datatype<\/strong>: Specifies the type of data the column holds (e.g., INT, VARCHAR(255), DECIMAL(10, 2), DATE, TIMESTAMP, BOOLEAN). Data types can vary slightly between RDBMS.<\/li>\n\n\n\n<li><strong>constraint<\/strong>: Optional rules applied to columns (e.g., NOT NULL, UNIQUE). We&#8217;ll cover constraints in more detail later.<\/li>\n\n\n\n<li><strong>PRIMARY KEY<\/strong>: A constraint that uniquely identifies each record in a table.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcBzNi39ZpVLGHg9EdIo2Wwi5G0dXn6eAbV52Xjs0K2wFQZmIcYtLK9ryho4lz-gqQYrVxeuynUETzIBSo2zA_BKZgVM0y6H2jtv1kqVD0Yi9jfW_PIVNpzwc8yTMRBKKPGtQ9bxvkKh2tidaCK-fo?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"inserting-data-insert-into\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Inserting_Data_INSERT_INTO\"><\/span><strong>Inserting Data (INSERT INTO)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>After creating a table, you can populate it with data using the INSERT INTO statement.<\/p>\n\n\n\n<p><strong>Syntax (inserting a single row)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfFoUwMNLuGPBRo6kLxuI3pQhZ3d5Yjnph4P_X6iwbCmGccbiimfTC48Ls6_f9oeLshnrR-AF08ASFaPgvoa87quwY8CJKn9vkmQXee54eZ8A8UgtKqRy-kqgawsA3oQcyE22ZiADqQJ7c5wQRFCTA?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The column list is optional if you provide values for <em>all<\/em> columns in the table&#8217;s defined order.<\/li>\n\n\n\n<li>Values must match the data types of the corresponding columns.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf02XXvqa7GA6IwcJU_tvEl3jUHs-x_QJ28v1O9IvCjlAnw6FTlK2WlH0Sj_GeH9_oy-MuiDskTMOEWbzvgiPxlvDsR2J8GtAgiPZxLA9hlvU4GauTK07QBBaDYBhwGBJFgwasfKyoZM5_TGGbnR0E?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Syntax (inserting multiple rows &#8211; varies slightly by RDBMS)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfES6rFUnBY2uctssLOEj1YWBweAU6GftQBAD09mfAu_depmArXF4uLHT_DKLaDd30gAv2YwDEI1oCANG9k7jy9Zni5kUxKR0u7-W2D7pUFQFcXlU9O0GCKT9sKEZ8uRHkzGtPA6Gws7CsYebqV6w?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXd3MS3UpclpBiiSsGCY0ghIIt0M0sV8c-lD2dR-CZ7jLl6jlpfSugUa_LeVpaJwM7Q00Z5y2lBZlDg8RGPEcdIcpjvNDUQFqCfmG8zIPkTXasJJ8avgLn7-vPhfknFAjEkxZ1xBXUgiGDebnrx_8LQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"reading-querying-data-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ReadingQuerying_Data_in_SQL\"><\/span><strong>Reading\/Querying Data in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The cornerstone of <a href=\"https:\/\/www.pickl.ai\/blog\/foreign-key-in-sql\/\">SQL<\/a> is retrieving data. This is done using the SELECT statement.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfl2MtxQU2QLnTmgHNjtvqvlfnG4QdkeHvIfkDQVEhSoYDq3LbhAE6MXzRhCGC80B9ypgSB9i26Qp-RM8PjSGIfW5mUJJIiAzkeuCi_rghaVSE5E7-j41l1f9gU9An1kJldhSH5I_WKFJDdYyGfD9U?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SELECT<\/strong>: Specifies the columns you want to retrieve.<\/li>\n\n\n\n<li><strong>FROM<\/strong>: Specifies the table(s) from which to retrieve the data.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"retrieve-all-columns\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Retrieve_all_columns\"><\/span><strong>Retrieve all columns<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Use the asterisk (*) as a wildcard.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfn13WAAg929WhIPyyvF8cOT8NRdvK6LeW5GZOaIzVQdY82-om2XuQD3JiasOKK_WCB5MZSD63u8qopc_SRGPYhjs1vXkLUQxcmzQitdOyEDp8MDdq0icxjFdbQTy-vv0T8viV5ASR3WkWSQ_mSaA?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"retrieve-specific-columns\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Retrieve_specific_columns\"><\/span><strong>Retrieve specific columns<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfXhFFCXF3n1WmlQEY2p2b1IlxENuBioAyjzdTj0JKrUaDrFIaUUnX-VwbPGoZKEFzfVFmfwagPViE2RaScAs7RCyeO65CX0ZX8m4fhFkASmiJ0yjnB3LDEHCfxxKzJ0gTZ6TX_Q8SlNyDadu8TnwQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"using-aliases-as\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_Aliases_AS\"><\/span><strong>Using Aliases (AS)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can rename columns or tables in the output for clarity.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcm2Lt_YCjTCN0dN6sMjpgVizO00HBqM0SE2xBiJBIQ6Dkpyg65hcvKM5xxA-vxDlQ1qUIwPF_A1SVF-73iJddzOgYblbZSncPR5rX5_vmsLj5mJoFj0rlIxTQWjzhTrnXysa9_aHo0MmAbxoCj0mE?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"updating-manipulating-data-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"UpdatingManipulating_Data_in_SQL\"><\/span><strong>Updating\/Manipulating Data in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Often, you need to modify existing data in your tables. The UPDATE statement is used for this.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXe4XDEOaQvuPGYQkk0-tF0oVNd4V-lT_BgaPOfT7oAQo3tfkm0Hon0apv--Cdl1NUKjN4W5rK79ot3wA1m5epQtXdcEomHZD4zdeAk0NG6eekkqBSVIj6LNhH1J2YXuao4e1qm6IKLwtCllJs9hfKU?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>UPDATE<\/strong>: The statement to modify existing records.<\/li>\n\n\n\n<li><strong>SET<\/strong>: Specifies the columns to update and their new values.<\/li>\n\n\n\n<li><strong>WHERE<\/strong>: <strong>Crucial!<\/strong> This clause filters which rows are updated. If you omit WHERE, <em>all rows<\/em> in the table will be updated. Always be cautious.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Update Alice Smith&#8217;s salary.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdFUSRwdGpBi5QWLM3ZTj7-gHpiHttXII-zMDlcLv78vCwl2sF-ueAdDLIbNZuAqHHP2BBiPZ6LWzq0u6H1-mKHamGAbOua4w5VMYQv9cIuGvT56DBm5R0joRoSU0FJXCLPj80uTaw0s9jeGrbErxc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Give everyone hired before 2023 a 5% raise.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXd_OgwzuQ68Yp8-Nx0rX9elquMI9272-Gjpq2WYuoBNfqOhhBxauxap4KVXQm_8WG_w5SW--zED8uq2G3VUDArHQ7X8eMoZWH4dlG7n23k5sfUCWJAymTfFIBjiK-cYt-sdESD7qnyNGf0MfBtMzgk?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"deleting-data-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deleting_Data_in_SQL\"><\/span><strong>Deleting Data in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Removing data can mean deleting specific rows, entire tables, or even whole databases.<\/p>\n\n\n\n<h3 id=\"deleting-rows-delete-from\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deleting_Rows_DELETE_FROM\"><\/span><strong>Deleting Rows (DELETE FROM)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Removes specific records from a table based on a condition.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXe5MJOJVGfR6dPeUEfQXIjvs6noI6vS_2IpCylZ-qFGxVgtm21skiawDQ0pZLibnetFGI0chAq9KneMCvEzdp2n6RvtScObli3t8uTdSicxAXvRTr82k6jgj3e4orumbjcr5i0WMGWAqWqjw5V97eE?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>DELETE FROM<\/strong>: The statement to remove rows.<\/li>\n\n\n\n<li><strong>WHERE<\/strong>: <strong>Extremely Important!<\/strong> Specifies which rows to delete. If omitted, <em>all rows<\/em> in the table will be deleted.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Delete the employee with employee_id 103<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfYDml94fw7D9ufYi7SPSxytmZw5t-j6gnWVe1hG74EiRtB6KeYOSRdOjRPPHCNcNUan31Sq_WjTBquN0rL1X916iiHlYbDO71PCxYwNY6MIN0WjcpOkmK9ZsOdTKKmAMIXBRDBoM0LVpZhJWp6HQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"deleting-all-rows-truncate-table\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deleting_All_Rows_TRUNCATE_TABLE\"><\/span><strong>Deleting All Rows (TRUNCATE TABLE)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A faster way to remove <em>all<\/em> rows from a table, but use caution. It often resets auto-increment counters and might not trigger certain database rules (like triggers) compared to DELETE.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXe-N89zHRUw_VR6VugmQ_lSQqj_Zy07Hs5unKYYJ1FcLRAnNeeYjXr3iyCkcR2i3FMWh0havyv9Jwrb44ce-6cbGsjL4AnGQ2nzixKa756T2OvtMzhzcepX0JvaeEpu33baSRpFmEuyHgovAaa499k?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"deleting-tables-drop-table\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deleting_Tables_DROP_TABLE\"><\/span><strong>Deleting Tables (DROP TABLE)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Removes the entire table structure and all its data permanently.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXewDCGFOrKcV3l6EFJKfg6V9hsYXgH2mZOH0SpBb0AGWlZ5ZOGs3OicVf8zEYF3m7IDM1XKCz_nZjWRbkFUkuNI5pMCeeJigwhEb5Q7PHeR8UzF0MpdGEjMR4sJZMcUhtB88VWx8ykRudaq52PcT5M?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong><strong><br><\/strong> <img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdzIo2g8Aj_wwyjIg8xtiSdj5cxIDFvKBL5TxGrWN2_l2Obi6ekPx8A9iccxoBjmOtnjW-qgvGCy9Hco6KNQiiXSjDT_bjHOmlKfZmX5KBFEdkNbJWcCIezI-oHBvMuer-MdNPS6ayYZHjRIZLjpYc?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"603\" height=\"53\"><\/p>\n\n\n\n<h3 id=\"deleting-databases-drop-database\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deleting_Databases_DROP_DATABASE\"><\/span><strong>Deleting Databases (DROP DATABASE)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Removes the entire database and all its contents (tables, views, etc.) permanently. Use with extreme caution!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcX0UPM37cTRCLYJXDGwiL-Yg7ReThh8MrV4pVlX5jLIi_CWaH7eGfP_f_aq327PV32_voRA9mnpX5cHRsdh2ZtRgE56vYlXiUYXfKlKT8w6vks9VP_kK136ZFH2fwK3Dp7O0X4UPSpkDZkmKrIKRg?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"filtering-data-in-sql-where\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Filtering_Data_in_SQL_WHERE\"><\/span><strong>Filtering Data in SQL (WHERE)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The WHERE clause is used with SELECT, UPDATE, and DELETE statements to filter records based on specified conditions.<\/p>\n\n\n\n<p><strong>Common Comparison Operators:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>= : Equal to<\/li>\n\n\n\n<li>!= or &lt;> : Not equal to<\/li>\n\n\n\n<li>> : Greater than<\/li>\n\n\n\n<li>&lt; : Less than<\/li>\n\n\n\n<li>>= : Greater than or equal to<\/li>\n\n\n\n<li>&lt;= : Less than or equal to<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Find employees with a salary greater than $70,000.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf4z_RU0uuFRkA6786w7l_7TtxRt40yc59rDJcZqDJIIomVDgV1yvb9vk_ux3iaCvIQ8e4_hqGlrLZqXNK5l4a6GRw_itYIFgrBztI3CS6HKHwK0yTqUQyotAfU9yYB8UU44io3MvHU9bZnWXjkGQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"logical-operators-and-or-not\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Logical_Operators_AND_OR_NOT\"><\/span><strong>Logical Operators (AND, OR, NOT)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Combine multiple conditions.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AND: Both conditions must be true.<\/li>\n\n\n\n<li>OR: At least one condition must be true.<\/li>\n\n\n\n<li>NOT: Reverses the truth value of a condition.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Find employees named &#8216;Bob&#8217; OR earning more than $60,000.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeWKGUCD0x_YluVmxlOFEp9o_KadZCTP6iQxpH9aGsqJHl1uRAv3nrIzZwbzjMACtFzNl80D2Az2YzLshp-6eWjKQvbSmnEE_nY4NlEoPTLomz8oPl6SQdFz4D8L8DaVRZom6kFDDQRtSgI11zy_4o?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Find employees NOT named &#8216;Alice&#8217;.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdZtJhHHZ-vRdWlznb-r_mVqLJqSSp_BAyDDaqvVN9eNkPWdvIl9Th0f5cbWdVE4UX2FF4EOjqnJGFXMVFlm0gjZ6CGc6t0OABraurVk7XazmqqDpcuFfhNfaIiW5VRJQ1htN91ZKO6Z4PaYjt0zvc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"other-useful-filtering-keywords\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Other_Useful_Filtering_Keywords\"><\/span><strong>Other Useful Filtering Keywords<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>BETWEEN<\/strong>: Checks if a value is within a range (inclusive).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcURKhmUg7_R7_MaxSAecnxBnzn7mit7h3O49VHKgmq7q0qSHYiK3pB_4vifJUY_g9qPzd2WExMxuZjTSPHCRi0oZOWulFN1X_rR4FUeKlm5aQLOPEZxdFV2zhcDqGWkYz_JPG7G0ucTntJT05SlLc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>IN<\/strong>: Checks if a value matches any value in a list.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfzhRztDQB4VGHJmL3aUJ8QophNUposzeIw5ahC2ePiM5NEfInHn9cflxNTN0-frqO_Xt6GAm8oOLtajRZKm7GFF0Rk1BF-JzuF3ay9YG6TGeDjEuKEalK1nfPKuaT6yzswTgBytncFvrjdUP5x5Q0?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>LIKE<\/strong>: Performs <a href=\"https:\/\/www.pickl.ai\/blog\/pattern-matching-in-sql\/\">pattern matching<\/a> using wildcards:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>%: Matches any sequence of zero or more characters.<\/li>\n\n\n\n<li>_: Matches any single character.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXc56rq7dibyYWyRjOQ79IqZoSkrRiSmb2CiSt95st_AsSiBOSLrMJJ55sLqfBT4egV7Koj85ow0a21DDm8XPhi4uB_sQt1-Jcx3rcvkgLEJKxHtKJ8rVjlRRMEPEX_H_jGKVNrMkH1f8C9yqSM4Q60?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>IS NULL \/ IS NOT NULL<\/strong>: Checks for null (missing) values.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdlhryuUNtP_T1GPUi4oMtJeNrNYbKUbMtA4AMk7kBzh6Zp5rpm_TKqTS_2xt5qbNg3lyTZ28Fm_-c_f3_CdWnOGR729Z_IDA7WsC3yhyEAw4jIfBbudfEXaXbO45aCUroujV94sRE2jhJY5CER4Gs?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"sql-operators\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"SQL_Operators\"><\/span><strong>SQL Operators<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Beyond filtering, SQL uses operators for calculations and comparisons.<\/p>\n\n\n\n<p><strong>Arithmetic Operators:<\/strong> +, -, *, \/, % (Modulo &#8211; remainder of division, syntax may var<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Comparison Operators:<\/strong> Covered in the WHERE clause section (=, !=, >, &lt;, >=, &lt;=).<\/li>\n\n\n\n<li><strong>Logical Operators:<\/strong> Covered in the WHERE clause section (AND, OR, NOT).<\/li>\n\n\n\n<li><strong>Set Operators:<\/strong> Combine results from two or more SELECT statements.\n<ul class=\"wp-block-list\">\n<li><strong>UNION<\/strong>: Combines results, removing duplicates. Columns must match in number and compatible data types.<\/li>\n\n\n\n<li><strong>UNION ALL<\/strong>: Combines results, including duplicates. Faster than UNION.<\/li>\n\n\n\n<li><strong>INTERSECT<\/strong>: Returns only rows that exist in <em>both<\/em> result sets (not supported by all RDBMS, e.g., MySQL).<\/li>\n\n\n\n<li><strong>EXCEPT<\/strong> (or <strong>MINUS<\/strong> in Oracle): Returns rows from the first result set that are <em>not<\/em> in the second (not supported by all RDBMS, e.g., MySQL).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfRh3gBL3z0fjB80NI0hk3I6-fpp-BvxtRa7tMGk-o5LnJuNfmgSjRQzmAmXAs9VmHsQEPemeqkyXNnmK4pRrVKf0aTUEnJ1stBmn9f9Ry4NEJLrxaAXIiOGYlvrEOVPFqOWiN8SdLG2t7Pr1vReuU?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"aggregating-data-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Aggregating_Data_in_SQL\"><\/span><strong>Aggregating Data in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.pickl.ai\/blog\/what-are-sql-aggregate-functions-types-and-importance\/\">Aggregate functions<\/a> perform calculations on a set of rows and return a single summary value. They are often used with the GROUP BY clause.<\/p>\n\n\n\n<p><strong>Common Aggregate Functions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>COUNT(): Counts the number of rows. COUNT(*) counts all rows; COUNT(column_name) counts non-NULL values in that column.<\/li>\n\n\n\n<li>SUM(): Calculates the sum of values in a numeric column.<\/li>\n\n\n\n<li>AVG(): Calculates the average of values in a numeric column.<\/li>\n\n\n\n<li>MIN(): Finds the minimum value in a column.<\/li>\n\n\n\n<li>MAX(): Finds the maximum value in a column.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Count the total number of employees.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcpnDlpQcawdNzsAsxYyyXsUBXKPdVOHM2qg5-WJrJVifBzg6BxFm6fNVQQEwyfLI9t09CqCOFLfmbQRfA3n6wbZ1tXn5tDheQPJTIgZGNqpJjxgmZ5FY6LmA_rQnQV0l1khqzbXgW9VzH8h2ePGsE?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Calculate the total and average salary.<br><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXd9ZM-wJJoaDgcVHHs2C1Tszrd1n8Ft9j24nxTHqGuur6RAc8bmczefuwKZBsR45aAUTQrrJZt2Ba6YWBu46P_QJI8IMIMDzIr_mNPcIW9v7ZyuL1lPWeS07EnCiX6ellQ-vy1U_xY2_l_7u-VgQg?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"601\" height=\"51\"><\/p>\n\n\n\n<h3 id=\"grouping-results-group-by\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Grouping_Results_GROUP_BY\"><\/span><strong>Grouping Results (GROUP BY)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Groups rows with the same values in one or more columns, allowing aggregate functions to operate on each group.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcCw9yzUXwpyXsNnFKoi5vsuxk1AEbvXqK47-HSgCZBzP_RQQlPt19uHg2F0VTejfZ5C6yj0MmDS-naZR5PawQjU6QQIfXHPy2ZHwUkQPNpFRH6Nf5yKCUjDWrqBW6cNA5McUwOiY5COluuMxBmhHs?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Count employees hired each year.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcMeTQOKKVOdxsZuPFB5YbsXXE8EiJIzol8lnJ8l_Cx8S-vifUGEKX2tIHA2QWOi9IYL0gVKHr1GKMKpVdfFadxaEaECbBcyej9sEP0xMCfW5CAvoDb0YIpnUAOtrN17N1xxlZAm--riMSAmVXTPg?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><em>(Note: YEAR() function extracts the year from a date; exact function name might vary by RDBMS).<\/em><\/p>\n\n\n\n<h3 id=\"filtering-groups-having\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Filtering_Groups_HAVING\"><\/span><strong>Filtering Groups (HAVING)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Filters groups <em>after<\/em> aggregation, based on the aggregate result. WHERE filters rows <em>before<\/em> aggregation.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXerXxhszwEMaosg3l-7_6tS8KzA4INf8QhJP06Iwp_V0WCdeebXrQqbPzox2BAZpjQxI7M_zkDYbcZfj85-tV1EJrqd-exEwDftM5PtLnV7djzIbfBwqfPrOaUaBtmBcU1kAeaG_8Uq9FxE69SdUYc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Find years where more than 1 employee was hired.<br><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdNSDtAK1khzI75cEg3yy49CYdXSusYxgjQoE5LrWKrvunQqNiRPYxIVzHPmy_MULmMkpf7MxoWM0FJmAqkxzkFPtnbH7StswCz-lDpgVZYT1wT5Yrmto8fbRAaUipDbr0jy7GczK8w0FLefC7672w?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"603\" height=\"149\"><\/p>\n\n\n\n<h2 id=\"constraints-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Constraints_in_SQL\"><\/span><strong>Constraints in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Constraints enforce rules on data in tables, ensuring data accuracy and integrity. They are typically defined during table creation (CREATE TABLE) or added later <a href=\"https:\/\/www.pickl.ai\/blog\/introduction-to-alter-table-command-in-sql\/\">(ALTER TABLE).<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>NOT NULL<\/strong>: Ensures a column cannot have a NULL value.<\/li>\n\n\n\n<li><strong>UNIQUE<\/strong>: Ensures all values in a column (or a set of columns) are distinct. NULLs are often treated specially (e.g., multiple NULLs might be allowed).<\/li>\n\n\n\n<li><strong>PRIMARY KEY<\/strong>: A combination of NOT NULL and UNIQUE. Uniquely identifies each row in a table. A table can have only one primary key (which might consist of multiple columns).<\/li>\n\n\n\n<li><strong>FOREIGN KEY<\/strong>: Establishes a link between two tables. It enforces referential integrity \u2013 values in the <a href=\"https:\/\/www.pickl.ai\/blog\/foreign-key-in-sql\/\">foreign key<\/a> column(s) must match values in the referenced table&#8217;s primary key column(s), or be NULL.<\/li>\n\n\n\n<li><strong>CHECK<\/strong>: Ensures that values in a column satisfy a specific condition (e.g., salary > 0).<\/li>\n\n\n\n<li><strong>DEFAULT<\/strong>: Sets a default value for a column if no value is specified during INSERT.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXftfiyEkxSE6ILDaiCudm_5YXGJMlxy7giU13jEkh_e2jobH_Hc89AMyMxGorgk1Qe5fMtcDywodae-UdAA1TpJy4ev5owBqiShGJNIvg2nFWmwHfxs3hGpID7IvTCB-_oRY4gd3MP-Yh2aSisr7H4?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"joins-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Joins_in_SQL\"><\/span><strong>Joins in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Joins combine rows from two or more tables based on a related column between them (usually a foreign key relationship).<\/p>\n\n\n\n<h3 id=\"inner-join\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"INNER_JOIN\"><\/span><strong>INNER JOIN<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Returns only the rows where the join condition is met in <em>both<\/em> tables. This is the most common type.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf54HWBHdS7Go1fngUTNk4_LMvr4_YFUcAkDLgsnPeQrag_zxk4fzYvVIDrGaZd6mji7kgQXGLeUMW5TOfjDNLcR70f_oVxBN29I-v5rKpjtFp98F9gm6n4np5gjhh3fH34sGHeBvrMJ0nap0BdPA?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><em>(e and d are table aliases for brevity)<\/em><\/p>\n\n\n\n<h3 id=\"left-join-or-left-outer-join\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"LEFT_JOIN_or_LEFT_OUTER_JOIN\"><\/span><strong>LEFT JOIN (or LEFT OUTER JOIN)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Returns all rows from the <em>left<\/em> table (the first table mentioned) and matching rows from the <em>right<\/em> table. If there&#8217;s no match in the right table, NULL values are returned for its columns.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeOFVibTdIFg8SvwuXFoOYlWvbr0oix_q8adFZEmhMzBjzBB9R7jAkDdeWqnZlj6i1I51dVvaoFbfyanlrw4cPZxaL7PS9toelRALsSkSCfKa6xMd2IT3a8-C9RfeeWa8KXZDA-6YJVXf_BxkEwNQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"right-join-or-right-outer-join\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"RIGHT_JOIN_or_RIGHT_OUTER_JOIN\"><\/span><strong>RIGHT JOIN (or RIGHT OUTER JOIN)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Returns all rows from the <em>right<\/em> table (the second table mentioned) and matching rows from the <em>left<\/em> table. If there&#8217;s no match in the left table, NULL values are returned for its columns.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcYld7ZHlGbPgVHm2jZ8iIKOahBIroiw7u7RRoWaKJwguiYNJ6sMCG_HHp6GTD7y-8QzgkVYhuytcN4EUR6g3h4aEU1nQx2od_mRoPRGZHRRDA6rgQXU2wC3wQ98aLxyUoivdKPUlZMJlfR7UL-_hc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"full-outer-join\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FULL_OUTER_JOIN\"><\/span><strong>FULL OUTER JOIN<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Returns all rows when there is a match in either the left or the right table. If there&#8217;s no match for a row from one side, NULLs are returned for columns from the other side. (Not supported by all RDBMS, e.g., MySQL).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf2DxGIbtHLwlp3w-kixs2av-oFGEMKJknTKvw5pVVeBYn6lTxYnhhEpc4PohHV2x1nt_-putUjvSE_t1O2s1M0DSbmDK5EDTDxGw2wBumqOmV-sc1OVcfiqq1foDKLIJWbwIwB_S70xbiIm5MJPVQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"cross-join\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"CROSS_JOIN\"><\/span><strong>CROSS JOIN<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Returns the Cartesian product of the two tables \u2013 every row from the first table combined with every row from the second table. Use with caution, as it can produce very large result sets. Often used without an ON clause.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXexlPfbkhScuOLEnBtW5JpCXGTn9iXMDJq75gbeFgoBLN7daJw9G9DXIxPCMIXHEcj0UegU85FDJtsH95ZbiyIHUIyEL6sM-y4XJ9JvFVmMQVOYHLn8TDTAkJQxsrjQ73IOiF8UzsZTisgtKuac-Hk?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"sql-functions\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"SQL_Functions\"><\/span><strong>SQL Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>SQL provides built-in functions to perform operations on data. They can be broadly categorized:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>String Functions:<\/strong> Manipulate text data. Examples:\n<ul class=\"wp-block-list\">\n<li>CONCAT() \/ ||: Concatenate strings (syntax varies).<\/li>\n\n\n\n<li>LENGTH() \/ LEN(): Get string length.<\/li>\n\n\n\n<li>SUBSTRING() \/ SUBSTR(): Extract a portion of a string.<\/li>\n\n\n\n<li>UPPER() \/ LOWER(): Convert case.<\/li>\n\n\n\n<li>REPLACE(): Replace occurrences of a substring.<\/li>\n\n\n\n<li>TRIM(): Remove leading\/trailing whitespace.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Numeric Functions:<\/strong> Perform mathematical operations. Examples:\n<ul class=\"wp-block-list\">\n<li>ROUND(): Round a number.<\/li>\n\n\n\n<li>CEILING() \/ FLOOR(): Round up\/down to the nearest integer.<\/li>\n\n\n\n<li>ABS(): Get the absolute value.<\/li>\n\n\n\n<li>MOD() \/ %: Modulo operator.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Date and Time Functions:<\/strong> Manipulate date\/time values. Examples:\n<ul class=\"wp-block-list\">\n<li>NOW() \/ CURRENT_TIMESTAMP: Get the current date and time.<\/li>\n\n\n\n<li>CURRENT_DATE: Get the current date.<\/li>\n\n\n\n<li>DATE() \/ YEAR() \/ MONTH() \/ DAY(): Extract parts of a date.<\/li>\n\n\n\n<li>DATE_ADD() \/ DATE_SUB() (syntax varies): Add or subtract time intervals.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Aggregate Functions:<\/strong> Already covered (COUNT, SUM, AVG, MIN, MAX).<\/li>\n\n\n\n<li><strong>Conversion Functions:<\/strong> Convert data types (e.g., CAST(), CONVERT()).<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXefzqWeSA3icgjrsPbTXAlPmlbkLMNrBNB61KehnjmHXpPOV4RtbjwsZ64uxDOpEZkveIw5OmrsFvAYKBI4o9y67RyRowh7o71ewAGrC2II7ANxYxG1T1BxcHrPNUMRf-FnIQfuXQL3h1xrErmuw1I?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"subqueries-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Subqueries_in_SQL\"><\/span><strong>Subqueries in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A subquery (or inner query) is an SQL query nested inside another SQL query (the outer query). They can appear in SELECT, FROM, WHERE, or HAVING clauses.<\/p>\n\n\n\n<p><strong>Example (in WHERE clause):<\/strong> Find employees whose salary is above the average salary.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXes37ohbeuEiJyjBfwlGIxsQKADcvhtUN5Q73s9zkMjojBlFSCGI-fiAL9-9r9q227GedigVXtMVy2wDoBdGGVX2eJvEPEBPNm1E0Qr9Oeuo1j3SyFo57fA4qkNR-hfVc34eyBvbt_i2F-jruYknuc?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example (in SELECT clause &#8211; Scalar Subquery):<\/strong> Show each employee&#8217;s salary and the company average.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdOUvd7cZGWWPTAJrxLPX44xrtl5oK43MJJ65czv2LF1ZYbG9Oo7MU5dfGgGI7JEBzJCoCMmp1mU0_Ml0QwOlgxdzdNJtAqb8SnyJAPUlZmWitWE865XTpMiXFXl3oElVyYjQCw_tavlfoJJNZtm8c?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example (in FROM clause &#8211; Derived Table)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdKT7_2ZpQgifNVsW6op-V_kT3tjpFC54cVUXRKw24LGW4e7gasYw4Tyk06VoY76kOVPZkfC9ChSIy4RKqsaDsYM67fYOYxcY6U4VAVgYe5YYu-pf8iQDY47dK41aFDwD8GSPxrI9uXPB8Q61lbM4c?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p>Subqueries can be <em>correlated<\/em> (inner query depends on the outer query) or <em>non-correlated<\/em> (inner query runs independently). Non-correlated subqueries are generally more efficient.<\/p>\n\n\n\n<h2 id=\"views-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Views_in_SQL\"><\/span><strong>Views in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A view is a virtual table based on the result set of a stored SQL query. It doesn&#8217;t store data itself but provides a way to look at data from one or more underlying tables.<\/p>\n\n\n\n<p><strong>Benefits:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Simplicity:<\/strong> Hide complex joins and calculations.<\/li>\n\n\n\n<li><strong>Security:<\/strong> Restrict access to specific columns or rows.<\/li>\n\n\n\n<li><strong>Consistency:<\/strong> Ensure users access data through a predefined structure.<\/li>\n<\/ul>\n\n\n\n<p><strong>Creating a View:<\/strong><strong><br><\/strong> <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXePaOYGSm-meYu3IsPzvhmb6pl9ejrk_j9rUfI_wbqLgZcGgNHhbZgISuIT_gvkXsWmMT6EreTB0xjtKJX_XlkMiKlpontUBUB5uJo3IrIIEPLgHXgdgRMJjjg1bzz0GfNqYKXi1qniu79iyGDbngU?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"603\" height=\"109\"><\/p>\n\n\n\n<p><strong>Example:<\/strong> Create a view showing employee names and their department names.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf92QLgvlUeDHYvoOf_j6IueaRkVWvRG60dqen1kAIx-6JMizt3h9K1-Li0BiLa4-Qt3XwuXUYvAeTn0dHqJ9UQ51_sK67NOoHahzlKJjAbj_Ir4xybEldbDqflHYoIumqx9BvXAxq9QJX-3hZPgTE?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Querying a View:<\/strong> Treat it like a regular table.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfLHAgHXl4uJFgXGui9dpuAsoOBX4h9gvaeWqmO-CGRYQ66osDehF7SOa7ISO_QyXAqJDVUgu-XNXRiRuuDd5rdaLXWTN6COLyT1iCJKmV1PN7g5TBuMCcgN-3RkB_5yiT7qo5JNUsB4Bg-8iJPxg?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Dropping a View:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdVr4x4eG32rHZ4zkmuywi35SSsnzPQelVEjL534UkVi5qwnMvWRZRkKCJu_pjvfTgWMtIqjUbB6X4B3SKFQ4UPfPgRuelE6g0fp8Opnz7mSkW0VnuQg5IlAg_gO1OjmfcgL00btLOIwNRfW8EXX9E?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"indexes-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Indexes_in_SQL\"><\/span><strong>Indexes in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>An index is a special lookup table that the database search engine can use to speed up data retrieval operations (SELECT queries). It&#8217;s like an index in the back of a book.<\/p>\n\n\n\n<p><strong>How it works:<\/strong> Indexes create pointers to data in tables based on the values in one or more columns. This allows the database to find rows matching WHERE clauses or join conditions more quickly, without scanning the entire table.<\/p>\n\n\n\n<p><strong>Creating an Index:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfGEfezScG9YFEus7O21aQI1F3T0lqLuxkAecfaG5j1HQ4OAyZ82SMMJhFp-vEots1MZ2SSZJvRGQ6iW7FVVwFVIDicbqMP7SZWO21cw85x51pYUB-to-pUBqW-FUCbNn5BOD7kRfPoM25D91fC0YU?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Create an index on the last_name column of the employees table.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeyUSx4fUjq741H_eHTDA4D8xbhDjNgz4HmmMNQtZOyqbm_XjGCkcNKKiiXuq7h99RXl77tIWsEYRBglS_lgZrF2HyWTcw0DhV1ictMqk8rqZMXcncEzFXFGhFf5X-TqzoklEJwIcW0vf5uDlLYbXs?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h3 id=\"trade-offs\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Trade-offs\"><\/span><strong>Trade-offs<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Faster Reads:<\/strong> Significantly improves SELECT query performance, especially on large tables.<\/li>\n\n\n\n<li><strong>Slower Writes:<\/strong> INSERT, UPDATE, and DELETE operations become slightly slower because the index also needs to be updated.<\/li>\n\n\n\n<li><strong>Storage Space:<\/strong> Indexes consume additional disk space.<\/li>\n<\/ul>\n\n\n\n<p>Indexes are automatically created for PRIMARY KEY and UNIQUE constraints. You should create additional indexes strategically on columns frequently used in WHERE clauses or JOIN conditions.<\/p>\n\n\n\n<h3 id=\"dropping-an-index\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Dropping_an_Index\"><\/span><strong>Dropping an Index<br> <\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXd7yPVf1b0LKjUegcpDmoEOlN1G9jhKnFSNuOFI7WO74NW8ZBsn-uDR-a2u8MW06Pjbgjx6mfoJh-O2U0MPa_-pV0Llu7pBvLchLmao8dtXZCITaPEnsl8Fd4d1s9vOqtxslHiZcQjiBMF8gW1yvGA?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"transactions-in-sql\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Transactions_in_SQL\"><\/span><strong>Transactions in SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A transaction is a sequence of SQL operations performed as a single logical unit of work. Transactions ensure data integrity using the ACID properties:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Atomicity:<\/strong> All operations within a transaction succeed, or none of them do. If any part fails, the entire transaction is rolled back.<\/li>\n\n\n\n<li><strong>Consistency:<\/strong> A transaction brings the database from one valid state to another. Constraints are enforced.<\/li>\n\n\n\n<li><strong>Isolation:<\/strong> Concurrent transactions do not interfere with each other. Each transaction behaves as if it were the only one running.<\/li>\n\n\n\n<li><strong>Durability:<\/strong> Once a transaction is successfully committed, its changes are permanent and survive system failures.<\/li>\n<\/ul>\n\n\n\n<p><strong>Key Commands:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>START TRANSACTION<\/strong> or <strong>BEGIN TRANSACTION<\/strong>: Marks the beginning of a transaction.<\/li>\n\n\n\n<li><strong>COMMIT<\/strong>: Saves all changes made during the transaction permanently.<\/li>\n\n\n\n<li><strong>ROLLBACK<\/strong>: Undoes all changes made since the START TRANSACTION.<\/li>\n\n\n\n<li><strong>SAVEPOINT savepoint_name<\/strong>: Creates a point within a transaction to which you can later roll back using ROLLBACK TO SAVEPOINT savepoint_name.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong> Transferring funds (requires both debit and credit to succeed)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfEQL3fBD2h80yG_FV8qgZh9tBky41bbM8jJvQB23ztKti-GbYj5q8U6DBq4Defuy_tky3DrmyQMZwVASefcJl_dSBhzwuM9e04SvmPJeCvjL_yiy7nB1e1juqU7Dwb1ZrZG15iGq-zv7AMC9Xoi3U?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><em>(Error handling logic depends on the specific SQL environment\/application code)<\/em><\/p>\n\n\n\n<h2 id=\"advanced-mixed-data-in-sql-case-statement\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Advanced_Mixed_Data_in_SQL_CASE_Statement\"><\/span><strong>Advanced Mixed Data in SQL (CASE Statement)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The <a href=\"https:\/\/www.pickl.ai\/blog\/case-statement-sql\/\">CASE statement provides conditional logic within SQL<\/a> queries, similar to if-then-else statements in programming languages.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXemBzImz0vukFVyn4pHAhfeQggJApAtYSUMyBuSUqtGX_JgwZecpls7UKZixT3TLthC5HO3trkvGuvrxIAwItyw0fBFcVTwf4AUFDwridruuRsR5nZfcY6ymVIfuxfliOpVgYcIIwTAAvJZa-IB8Q?key=yLuoGbZ3n6gDa9IcbyrXDw\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Example:<\/strong> Categorize employees based on salary.<br><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXezT11dv1_NQFsylJp782_0clVup6s_TGiV3gMgo4bYAKtZ_ngVfHcQz7veBGR_-TIO95MUN677xVF2bi-rK7JwD-_UUbNBh0O_hWoblslwWFgSen3Nft6TaHhH7oGvryLxJw5sOjDxm-q2S6gEbQ?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"603\" height=\"183\"><\/p>\n\n\n\n<h3 id=\"common-table-expressions-ctes\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Common_Table_Expressions_CTEs\"><\/span><strong>Common Table Expressions (CTEs)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Another advanced feature, CTEs (WITH &#8230; AS), allow you to define temporary, named result sets within a single SQL statement. They improve readability and organization for complex queries, often replacing subqueries or views for specific tasks.<br><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcOMIQIqkR8Y721WnB5YhdO0RPEwxSITk4gIoQYjwcgmQoEugab2B2rTyBxhfFL0UgeZmmc_CY_1ju8OdLBI2UKdu_8KgpeNBROdeCfaLWamDtfGWakO9oQeQYvm27Q-91Emi6jwCoYpN_UDFh99UU?key=yLuoGbZ3n6gDa9IcbyrXDw\" width=\"603\" height=\"179\"><\/p>\n\n\n\n<h2 id=\"conclusion\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>SQL is a powerful and essential language for anyone working with data. This cheat sheet provides a solid foundation and a quick reference for the most common commands and concepts. From creating databases and tables to performing complex queries with joins, aggregations, and conditional logic, you now have a map to navigate the SQL landscape.<\/p>\n\n\n\n<p>Remember, proficiency comes with practice. Experiment with these commands, explore your specific database system&#8217;s documentation for flavour variations and additional features, and tackle real-world data problems. Happy querying!<\/p>\n\n\n\n<h2 id=\"frequently-asked-questions\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span><strong>Frequently Asked Questions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 id=\"what-is-an-sql-cheat-sheet\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_Is_an_SQL_Cheat_Sheet\"><\/span><strong>What Is an SQL Cheat Sheet?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>An SQL Cheat Sheet is a concise reference guide <a href=\"https:\/\/www.pickl.ai\/blog\/sql-commands-list\/\">listing common SQL commands<\/a>, syntax, functions, and concepts. It helps users quickly look up how to perform specific database operations like querying, updating, or structuring data, serving as a handy reminder for both beginners and experienced professionals.<\/p>\n\n\n\n<h3 id=\"what-are-the-essential-sql-commands-covered-in-a-cheat-sheet\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_are_the_Essential_SQL_Commands_Covered_in_A_Cheat_Sheet\"><\/span><strong>What are the Essential SQL Commands Covered in A Cheat Sheet?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Essential commands typically include SELECT (for querying), INSERT INTO (for adding data), UPDATE (for modifying data), and DELETE (for removing data). Core concepts like CREATE DATABASE\/TABLE, WHERE clauses (filtering), JOINs (combining tables), aggregate functions (COUNT, SUM, AVG), and GROUP BY are also fundamental.<\/p>\n\n\n\n<h3 id=\"how-can-an-sql-cheat-sheet-help-beginners\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_Can_an_SQL_Cheat_Sheet_Help_Beginners\"><\/span><strong>How Can an SQL Cheat Sheet Help Beginners?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For beginners, a cheat sheet demystifies SQL by providing clear syntax examples for basic operations. It acts as a quick lookup tool, reducing the need to memorize everything upfront. Seeing commands grouped logically (like CRUD operations or filtering) helps build a foundational understanding of SQL&#8217;s structure and capabilities.<\/p>\n\n\n\n<h3 id=\"can-i-create-my-own-sql-cheat-sheet\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Can_I_Create_My_Own_SQL_Cheat_Sheet\"><\/span><strong>Can I Create My Own SQL Cheat Sheet?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Absolutely! Creating your own cheat sheet is a great learning exercise. Tailor it to the specific SQL flavour you use most (e.g., MySQL, PostgreSQL) and include the commands, functions, and complex query patterns you encounter frequently in your work. Personalizing it makes it even more effective.<\/p>\n","protected":false},"excerpt":{"rendered":"Quick reference for essential SQL commands to simplify database management and querying tasks.\n","protected":false},"author":4,"featured_media":21065,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1855,613],"tags":[3892],"ppma_author":[2169,2185],"class_list":{"0":"post-21064","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-cheat-sheets-for-data-scientists","8":"category-sql","9":"tag-sql-cheat-sheet"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Cheat Sheet: From Basics to Advanced Queries<\/title>\n<meta name=\"description\" content=\"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.\" \/>\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.pickl.ai\/blog\/sql-cheat-sheet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries\" \/>\n<meta property=\"og:description\" content=\"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/\" \/>\n<meta property=\"og:site_name\" content=\"Pickl.AI\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-04T07:53:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-24T10:49:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"333\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Neha Singh, Ajay Goyal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neha Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/\"},\"author\":{\"name\":\"Neha Singh\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/#\\\/schema\\\/person\\\/2ad633a6bc1b93bc13591b60895be308\"},\"headline\":\"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries\",\"datePublished\":\"2025-04-04T07:53:33+00:00\",\"dateModified\":\"2025-07-24T10:49:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/\"},\"wordCount\":2727,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/image35.jpg\",\"keywords\":[\"sql cheat sheet\"],\"articleSection\":[\"Cheat Sheets for Data Scientists\",\"SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/\",\"url\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/\",\"name\":\"SQL Cheat Sheet: From Basics to Advanced Queries\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/image35.jpg\",\"datePublished\":\"2025-04-04T07:53:33+00:00\",\"dateModified\":\"2025-07-24T10:49:31+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/#\\\/schema\\\/person\\\/2ad633a6bc1b93bc13591b60895be308\"},\"description\":\"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/image35.jpg\",\"contentUrl\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/image35.jpg\",\"width\":1000,\"height\":333,\"caption\":\"Image showing sql mastery: a comprehensive guide.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/sql-cheat-sheet\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cheat Sheets for Data Scientists\",\"item\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/category\\\/cheat-sheets-for-data-scientists\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/\",\"name\":\"Pickl.AI\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/#\\\/schema\\\/person\\\/2ad633a6bc1b93bc13591b60895be308\",\"name\":\"Neha Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/avatar_user_4_1717572961-96x96.jpg3d1a0d35d7a1a929f4a120e9053cbdb5\",\"url\":\"https:\\\/\\\/pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/avatar_user_4_1717572961-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/pickl.ai\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/avatar_user_4_1717572961-96x96.jpg\",\"caption\":\"Neha Singh\"},\"description\":\"I\u2019m a full-time freelance writer and editor who enjoys wordsmithing. The 8 years long journey as a content writer and editor has made me relaize the significance and power of choosing the right words. Prior to my writing journey, I was a trainer and human resource manager. WIth more than a decade long professional journey, I find myself more powerful as a wordsmith. As an avid writer, everything around me inspires me and pushes me to string words and ideas to create unique content; and when I\u2019m not writing and editing, I enjoy experimenting with my culinary skills, reading, gardening, and spending time with my adorable little mutt Neel.\",\"url\":\"https:\\\/\\\/www.pickl.ai\\\/blog\\\/author\\\/nehasingh\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Cheat Sheet: From Basics to Advanced Queries","description":"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.","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.pickl.ai\/blog\/sql-cheat-sheet\/","og_locale":"en_US","og_type":"article","og_title":"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries","og_description":"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.","og_url":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/","og_site_name":"Pickl.AI","article_published_time":"2025-04-04T07:53:33+00:00","article_modified_time":"2025-07-24T10:49:31+00:00","og_image":[{"width":1000,"height":333,"url":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","type":"image\/jpeg"}],"author":"Neha Singh, Ajay Goyal","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Neha Singh","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#article","isPartOf":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/"},"author":{"name":"Neha Singh","@id":"https:\/\/www.pickl.ai\/blog\/#\/schema\/person\/2ad633a6bc1b93bc13591b60895be308"},"headline":"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries","datePublished":"2025-04-04T07:53:33+00:00","dateModified":"2025-07-24T10:49:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/"},"wordCount":2727,"commentCount":0,"image":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","keywords":["sql cheat sheet"],"articleSection":["Cheat Sheets for Data Scientists","SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/","url":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/","name":"SQL Cheat Sheet: From Basics to Advanced Queries","isPartOf":{"@id":"https:\/\/www.pickl.ai\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#primaryimage"},"image":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","datePublished":"2025-04-04T07:53:33+00:00","dateModified":"2025-07-24T10:49:31+00:00","author":{"@id":"https:\/\/www.pickl.ai\/blog\/#\/schema\/person\/2ad633a6bc1b93bc13591b60895be308"},"description":"Explore this comprehensive SQL Cheat Sheet, featuring essential commands, syntax, and examples for database management.","breadcrumb":{"@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#primaryimage","url":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","contentUrl":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","width":1000,"height":333,"caption":"Image showing sql mastery: a comprehensive guide."},{"@type":"BreadcrumbList","@id":"https:\/\/www.pickl.ai\/blog\/sql-cheat-sheet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pickl.ai\/blog\/"},{"@type":"ListItem","position":2,"name":"Cheat Sheets for Data Scientists","item":"https:\/\/www.pickl.ai\/blog\/category\/cheat-sheets-for-data-scientists\/"},{"@type":"ListItem","position":3,"name":"Your Ultimate SQL Cheat Sheet: From Beginner Basics to Advanced Queries"}]},{"@type":"WebSite","@id":"https:\/\/www.pickl.ai\/blog\/#website","url":"https:\/\/www.pickl.ai\/blog\/","name":"Pickl.AI","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pickl.ai\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.pickl.ai\/blog\/#\/schema\/person\/2ad633a6bc1b93bc13591b60895be308","name":"Neha Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pickl.ai\/blog\/wp-content\/uploads\/2024\/06\/avatar_user_4_1717572961-96x96.jpg3d1a0d35d7a1a929f4a120e9053cbdb5","url":"https:\/\/pickl.ai\/blog\/wp-content\/uploads\/2024\/06\/avatar_user_4_1717572961-96x96.jpg","contentUrl":"https:\/\/pickl.ai\/blog\/wp-content\/uploads\/2024\/06\/avatar_user_4_1717572961-96x96.jpg","caption":"Neha Singh"},"description":"I\u2019m a full-time freelance writer and editor who enjoys wordsmithing. The 8 years long journey as a content writer and editor has made me relaize the significance and power of choosing the right words. Prior to my writing journey, I was a trainer and human resource manager. WIth more than a decade long professional journey, I find myself more powerful as a wordsmith. As an avid writer, everything around me inspires me and pushes me to string words and ideas to create unique content; and when I\u2019m not writing and editing, I enjoy experimenting with my culinary skills, reading, gardening, and spending time with my adorable little mutt Neel.","url":"https:\/\/www.pickl.ai\/blog\/author\/nehasingh\/"}]}},"jetpack_featured_media_url":"https:\/\/www.pickl.ai\/blog\/wp-content\/uploads\/2025\/04\/image35.jpg","authors":[{"term_id":2169,"user_id":4,"is_guest":0,"slug":"nehasingh","display_name":"Neha Singh","avatar_url":"https:\/\/pickl.ai\/blog\/wp-content\/uploads\/2024\/06\/avatar_user_4_1717572961-96x96.jpg","first_name":"Neha","user_url":"","last_name":"Singh","description":"I\u2019m a full-time freelance writer and editor who enjoys wordsmithing. The 8 years long journey as a content writer and editor has made me relaize the significance and power of choosing the right words. Prior to my writing journey, I was a trainer and human resource manager. WIth more than a decade long professional journey, I find myself more powerful as a wordsmith. As an avid writer, everything around me inspires me and pushes me to string words and ideas to create unique content; and when I\u2019m not writing and editing, I enjoy experimenting with my culinary skills, reading, gardening, and spending time with my adorable little mutt Neel."},{"term_id":2185,"user_id":16,"is_guest":0,"slug":"ajaygoyal","display_name":"Ajay Goyal","avatar_url":"https:\/\/pickl.ai\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_16_1695814138-96x96.png","first_name":"Ajay","user_url":"","last_name":"Goyal","description":"I am Ajay Goyal, a civil engineering background with a passion for data analysis. I've transitioned from designing infrastructure to decoding data, merging my engineering problem-solving skills with data-driven insights. I am currently working as a Data Analyst in TransOrg. Through my blog, I share my journey and experiences of data analysis."}],"_links":{"self":[{"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/posts\/21064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/comments?post=21064"}],"version-history":[{"count":2,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/posts\/21064\/revisions"}],"predecessor-version":[{"id":23363,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/posts\/21064\/revisions\/23363"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/media\/21065"}],"wp:attachment":[{"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/media?parent=21064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/categories?post=21064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/tags?post=21064"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.pickl.ai\/blog\/wp-json\/wp\/v2\/ppma_author?post=21064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}