SQL Tutorial
Learn SQL
SQL is a standard language for storingmanipulating and retrieving data in databases.
Our SQL tutorial will teach you how to use SQL in MySQLSQL ServerMS AccessOraclePostgreSQLand more.
Become SQL Certified
Get certified with our SQL examincludes a professionally curated study kit to guide you from beginner to exam-ready.
Examples in Each Chapter
With our online SQL editoryou can edit the SQL statementsand click on a button to view the result.
Click on the "Try it Yourself" button to see how it works.
SQL Exercises
Many chapters in this tutorial end with an exercise where you can check your level of knowledge.
SQL Examples
Learn by examples! This tutorial supplements all explanations with clarifying examples.
SQL Quiz Test
Test your SQL skills at W3Schools!
<> .containerlog { display: flex; gap: 50px; margin: 0; font-family: Arialsans-serif; margin-right:-16px; } .left-panel { flex: 50%; } .left-panel h2 { margin-bottom: 18px; } .checklist { list-: none; padding: 0; margin: 0; } .checklist li { display: flex; align-items: center; margin-bottom: 20px; font-size: 16px; } .checklist img { width: 20px; height: 20px; margin-right: 15px; } .right-panel { flex: 50%; display: flex; background-image: url("/images/img_db2.svg"); background-repeat: no-repeat; background-size: cover; margin-top:-50px; border-radius:8px; border:1px solid #f1f1f1; } @media (max-width: 1250px) and (min-width: 993px) { .right-panel { display: none; } } @media (max-width: 860px) and (min-width: 0px) { .right-panel { display: none; } .containerlog { margin-right: 0!important; } } .darkpagetheme .right-panel { background-image: url("/images/banner_dm.png"); border:1px solid #333; } >
Track Your Progress
Create a W3Schools account and get access to more features and learning materials:
View your completed tutorialsexercisesand quizzes
Keep an eye on your progress and daily streaks
Join the leaderboard and compete with others
Get your own avatar and unlock new skins
Create your own personal website
Note
This is an optional feature. You can study at W3Schools without creating an account.
SQL References
At W3Schools you will find a complete reference for keywords and functions:
<> .ref-grid { display: grid; grid-template-columns: repeat(auto-fitminmax(220px1fr)); gap: 16px; margin-top: 20px; } .ref-box { display: flex; align-items: center; justify-content: center; background-color: #E7E9EB; border: 1px solid #ddd; border-radius: 5px; padding: 14px; text-align: center; font-size: 17px; color: #333; text-decoration: none; } .ref-box:hover { background-color: #D5D7D9; color:black; } >SQL Data Types
Data types and ranges for Microsoft AccessMySQL and SQL Server.
<> #w3_cert_cta { margin: 10px 0 50px 0; border-radius: 8px; padding: 20px; border: 1px solid #f1f1f1; } #w3_cert_cta .ws-cert-flex { display: flex; gap: 32px; align-items: center; } #w3_cert_cta .ws-cert-col { min-width: 0; } #w3_cert_cta .ws-cert-col-7 { flex: 0 0 calc(58.333333% - 16px); max-width: calc(58.333333% - 16px); } #w3_cert_cta .ws-cert-col-5 { flex: 0 0 calc(41.666667% - 16px); max-width: calc(41.666667% - 16px); } #w3_cert_cta .ws-cert-hero { padding: 0; } #w3_cert_cta .ws-cert-hero-copy { padding: 8px 20px 8px 0; } #w3_cert_cta .ws-cert-kicker { display: inline-block; margin-bottom: 18px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #04AA6D; } #w3_cert_cta .ws-cert-hero h2 { margin: 0 0 22px 0; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; color: #1f2937; } #w3_cert_cta .ws-cert-hero p { margin: 0 0 16px 0; font-size: 16px; line-height: 1.75; color: #444; max-width: 590px; } #w3_cert_cta .ws-cert-hero-actions { margin-top: 24px; } #w3_cert_cta .ws-cert-hero-actions a.ws-btn { font-size: 18px; } #w3_cert_cta .ws-cert-hero-visual { display: flex; align-items: flex-start; } #w3_cert_cta .ws-cert-hero-card { border-radius: 5px; width: 100%; position: relative; background: linear-gradient(135deg#f8fbf9 0%#f3f7f4 100%); border: 1px solid #eceff3; padding: 26px; display: flex; align-items: center; justify-content: center; overflow: visible; } #w3_cert_cta .ws-cert-hero-image-link { display: block; width: 100%; text-decoration: none; color: inherit; } #w3_cert_cta .ws-cert-hero-image { position: relative; width: 100%; max-width: 270px; margin: 0 auto; padding-bottom: 18px; } #w3_cert_cta .ws-cert-hero-image img { display: block; width: 100%; height: auto; border-radius: 4px; position: relative; z-index: 2; } #w3_cert_cta .ws-cert-badge { position: absolute; left: -22px; bottom: -18px; width: 68px; height: 68px; z-index: 2; pointer-events: none; } #w3_cert_cta .ws-cert-badge svg { width: 100%; height: 100%; display: block; } #w3_cert_cta .ws-cert-image-fallback { display: none; width: 100%; min-height: 300px; border-radius: 10px; padding: 20px; background: radial-gradient(circle at top rightrgba(4,170,109,0.18)transparent 35%), linear-gradient(135deg#ffffff 0%#eef7f2 100%); border: 1px solid #dde9e1; position: relative; z-index: 1; } #w3_cert_cta .ws-cert-image-fallback-inner { height: 100%; min-height: 258px; border-radius: 10px; border: 2px dashed #cfe6d9; display: flex; flex-direction: column; justify-content: center; padding: 24px; text-align: center; } #w3_cert_cta .ws-cert-image-fallback-small { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #04AA6D; margin-bottom: 10px; } #w3_cert_cta .ws-cert-image-fallback-title { font-size: 34px; line-height: 1.15; font-weight: 700; color: #1f2937; margin-bottom: 12px; } #w3_cert_cta .ws-cert-image-fallback-text { font-size: 17px; line-height: 1.7; color: #000; } #w3_cert_cta .ws-cert-image-fallback.show { display: block; } #w3_cert_cta .ws-cert-hero-image.hide-img img { display: none; } body.darkpagetheme #w3_cert_cta { border-color: #444; } body.darkpagetheme #w3_cert_cta .ws-cert-hero h2 { color: #fff; } body.darkpagetheme #w3_cert_cta .ws-cert-hero p { color: #ddd; } body.darkpagetheme #w3_cert_cta .ws-cert-hero-card { background: linear-gradient(135deg#252a2f 0%#1f2428 100%); border-color: #444; } body.darkpagetheme #w3_cert_cta .ws-cert-image-fallback { background: radial-gradient(circle at top rightrgba(4,170,109,0.14)transparent 35%), linear-gradient(135deg#252a2f 0%#1f2428 100%); border-color: #444; } body.darkpagetheme #w3_cert_cta .ws-cert-image-fallback-inner { border-color: #3d4b43; } body.darkpagetheme #w3_cert_cta .ws-cert-image-fallback-title { color: #fff; } body.darkpagetheme #w3_cert_cta .ws-cert-image-fallback-text { color: #ddd; } @media (max-width: 1100px) { #w3_cert_cta .ws-cert-flex { gap: 24px; } #w3_cert_cta .ws-cert-hero-copy { padding-right: 0; } } @media (max-width: 992px) { #w3_cert_cta { margin: 45px 0 65px 0; } #w3_cert_cta .ws-cert-flex { display: block; } #w3_cert_cta .ws-cert-col, #w3_cert_cta .ws-cert-col-7, #w3_cert_cta .ws-cert-col-5 { max-width: 100%; width: 100%; } #w3_cert_cta .ws-cert-hero-copy { margin-bottom: 28px; } #w3_cert_cta .ws-cert-hero h2 { font-size: 32px; } #w3_cert_cta .ws-cert-hero-visual { margin-top: 18px; display: block; } #w3_cert_cta .ws-cert-hero-card { padding: 22px; } #w3_cert_cta .ws-cert-hero-image { max-width: 290px; margin: 0 auto; padding-bottom: 16px; } #w3_cert_cta .ws-cert-badge { left: -12px; bottom: -10px; width: 62px; height: 62px; } #w3_cert_cta .ws-cert-image-fallback { min-height: 260px; } #w3_cert_cta .ws-cert-image-fallback-inner { min-height: 220px; } } @media (max-width: 600px) { #w3_cert_cta { margin: 35px 0 55px 0; } #w3_cert_cta .ws-cert-hero h2 { font-size: 29px; line-height: 1.08; } #w3_cert_cta .ws-cert-hero p { font-size: 16px; } #w3_cert_cta .ws-cert-hero-card { padding: 18px; } #w3_cert_cta .ws-cert-hero-image { max-width: 220px; padding-bottom: 14px; } #w3_cert_cta .ws-cert-badge { left: -8px; bottom: -8px; width: 56px; height: 56px; } #w3_cert_cta .ws-cert-hero-actions a.ws-btn { width: 100%; text-align: center; font-size: 17px; } #w3_cert_cta .ws-cert-image-fallback-title { font-size: 28px; } #w3_cert_cta .ws-cert-image-fallback-text { font-size: 15px; } } >
Get Certified in coding
Complete the W3Schools coding coursestrengthen your knowledgeand earn a certificate you can add to your CVportfolioand LinkedIn profile.