[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-572211-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-572211-en":127},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","sql-basics-cheat-sheet","SQL Basics Cheat Sheet","","SQL Basics Cheat Sheet summarizes core concepts and practical queries for working with relational databases. It explains how SQL (Structured Query Language) is used to select specific data and build complex reports, then provides example tables and query patterns. Topics include selecting columns, ordering results, using aliases, filtering with comparison and text operators, null handling, range queries, and retrieving data via single-table and multi-table joins (INNER/LEFT/RIGHT/FULL/CROSS/NATURAL).",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/sql-basics-cheat-sheet/572211/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/sql-basics-cheat-sheet/572211.png","ImageObject",442,249,{"name":42,"@type":43},"Putri","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",7,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What is SQL used for in this cheat sheet?","Question",{"text":63,"@type":64},"SQL is used to talk to databases, select specific data, and build complex reports.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do you sort results by a column?",{"text":68,"@type":64},"Use ORDER BY with either ASC for ascending or DESC for descending, for example ORDER BY rating DESC.",{"name":70,"@type":61,"acceptedAnswer":71},"Which JOIN types does the cheat sheet cover?",{"text":72,"@type":64},"It covers INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL (OUTER) JOIN, CROSS JOIN, and NATURAL JOIN, with example queries and expected outputs.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},572211,1792128206,{"code":4,"msg":82,"data":83},"success",[84,88,93,98,103,108,113,118,123],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":86,"slug":87},11,90,"presentations",{"id":89,"doc_module":22,"doc_module_name":25,"category_name":90,"show_sort_weight":91,"slug":92},12,"Resumes",80,"resumes",{"id":94,"doc_module":22,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},14,"Invoices",70,"invoices",{"id":99,"doc_module":22,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},15,"Posters",60,"posters",{"id":104,"doc_module":22,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},16,"Social Media",50,"social-media",{"id":109,"doc_module":22,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},17,"Forms",40,"forms",{"id":114,"doc_module":22,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},18,"Letters",30,"letters",{"id":119,"doc_module":22,"doc_module_name":25,"category_name":120,"show_sort_weight":121,"slug":122},21,"Paper Templates",5,"papers-templates",{"id":124,"doc_module":22,"doc_module_name":25,"category_name":125,"show_sort_weight":4,"slug":126},158,"General","general-158",{"code":4,"msg":82,"data":128},{"doc_id":79,"user_id":129,"nickname":42,"user_avatar":130,"doc_module":22,"category_id":85,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":136,"language":137,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":138,"faqs":139,"seo_title":140,"seo_description":12,"update_tm":141,"read_time":30},962085571259,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","SQL Basics Cheat Sheet   \n\n| SQL\u003Cbr>SQL, or Structured Query Language, is a language to talk to databases. It allows you to select specific data and to build complex reports. Today, SQL is a universal language of data. It is used in practically all technologies that process data.\u003Cbr>SAMPLE DATA |  |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| COUNTRY |  |  |  |  |  |  |  |  |\n| id |  | name |  | population |  | area |  |  |\n| 1 |  | France |  | 66600000 |  | 640680 |  |  |\n| 2 |  | Germany |  | 80700000 |  | 357000 |  |  |\n| ... |  | ... |  | ... |  | ... |  |  |\n|  |  |  |  |  |  |  |  |  |\n| CITY |  |  |  |  |  |  |  |  |\n| id | name |  | country_id |  | population |  | rating |  |\n| 1 | Paris |  | 1 |  | 2243000 |  | 5 |  |\n| 2 | Berlin |  | 2 |  | 3460000 |  | 3 |  |\n| ... | ... |  | ... |  | ... |  | ... |  |\n| QUERYING SINGLE TABLE\u003Cbr>Fetch all columns from the country table: SELECT *\u003Cbr>FROM country;\u003Cbr>Fetch id and name columns from the city table:\u003Cbr>SELECT id, name FROM city;\u003Cbr>Fetch city names sorted by the rating column in the default ASCending order:\u003Cbr>SELECT name FROM city\u003Cbr>ORDER BY rating [ASC];\u003Cbr>Fetch city names sorted by the rating column in the DESCending order:\u003Cbr>SELECT name FROM city\u003Cbr>ORDER BY rating DESC;\u003Cbr>ALIASES COLUMNS\u003Cbr>SELECT name AS city_name FROM city;\u003Cbr>TABLES\u003Cbr>SELECT [co.name](co.name) , [ci.name](ci.name)[ ](ci.name)FROM city AS ci\u003Cbr>JOIN country AS co\u003Cbr>ON [ci.country_id = co.id](ci.country_id = co.id) ; |  |  |  |  |  |  |  |  |\n\nFILTERING THE OUTPUT COMPARISON OPERATORS  \nFetch names of cities that have a rating above 3:  \nSELECT name FROM city  \nWHERE rating > 3;  \nFetch names of cities that are neither Berlin nor Madrid:  \nSELECT name FROM city  \nWHERE name != 'Berlin'AND name != 'Madrid';  \nTEXT OPERATORS  \nFetch names of cities that start with a 'P' or end with an 's':  \nSELECT name FROM city  \nWHERE name LIKE 'P%'OR name LIKE '%s';  \nFetch names of cities that start with any letter followed by'ublin' (like Dublin in Ireland or Lublin in Poland):  \nSELECT name FROM city  \nWHERE name LIKE '_ublin';  \nOTHER OPERATORS  \nFetch names of cities that have a population between 500K and 5M:  \nSELECT name FROM city  \nWHERE population BETWEEN 500000 AND 5000000;  \nFetch names of cities that don't miss a rating value:  \nSELECT name FROM city  \nWHERE rating IS NOT NULL;  \nFetch names of cities that are in countries with IDs 1, 4, 7, or 8:  \nSELECT name FROM city  \nWHERE country_id IN (1, 4, 7, 8);  \nQUERYING MULTIPLE TABLES INNER JOIN  \nJOIN (or explicitly INNER JOIN) returns rows that have matching values in both tables.  \nSELECT [city.name](city.name) , [country.name](country.name)[ ](country.name)FROM city  \n[INNER] JOIN country  \nON [city.country_id = country.id](city.country_id = country.id) ;  \n\n| CITY |  |  | COUNTRY |  |\n| --- | --- | --- | --- | --- |\n| id | name | country_id | id | name |\n| 1 | Paris | 1 | 1 | France |\n| 2 | Berlin | 2 | 2 | Germany |\n| 3 | Warsaw | 4 | 3 | Iceland |\n\nLEFT JOIN  \nLEFT JOIN returns all rows from the left table with corresponding rows from the right table. If there's no matching row, NULLs are returned as values from the second table.  \nSELECT [city.name](city.name) , [country.name](country.name)[ ](country.name)FROM city  \nLEFT JOIN country  \nON [city.country_id = country.id](city.country_id = country.id) ;  \n\n| CITY |  |  | COUNTRY |  |\n| --- | --- | --- | --- | --- |\n| id | name | country_id | id | name |\n| 1 | Paris | 1 | 1 | France |\n| 2 | Berlin | 2 | 2 | Germany |\n| 3 | Warsaw | 4 | NULL | NULL |\n\nRIGHT JOIN  \nRIGHT JOIN returns all rows from the right table with corresponding rows from the left table. If there's no matching row, NULLs are returned as values from the left table.  \nSELECT [city.name](city.name) , [country.name](country.name)[ ](country.name)FROM city  \nRIGHT JOIN country  \nON [city.country_id = country.id](city.country_id = country.id) ;  \n\n| CITY |  |  | COUNTRY |  |\n| --- | --- | --- |","cbCaip7nLM1x99Ar","https://ap.wps.com/l/cbCaip7nLM1x99Ar","pdf",476190,8,"English","# SQL Basics\n## Sample Data\n## Querying Single Table\n## Filtering the Output\n## Text and Other Operators\n## Querying Multiple Tables with Joins","[{\"question\":\"What is SQL used for in this cheat sheet?\",\"answer\":\"SQL is used to talk to databases, select specific data, and build complex reports.\"},{\"question\":\"How do you sort results by a column?\",\"answer\":\"Use ORDER BY with either ASC for ascending or DESC for descending, for example ORDER BY rating DESC.\"},{\"question\":\"Which JOIN types does the cheat sheet cover?\",\"answer\":\"It covers INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL (OUTER) JOIN, CROSS JOIN, and NATURAL JOIN, with example queries and expected outputs.\"}]","SQL Basics Cheat Sheet | PDF",1791926164]