Welcome to your comprehensive SQL basics cheat sheet! Structured Query Language, or SQL, is an essential tool for database management and manipulation. This guide will empower you to interact confidently with databases, creating, updating, and retrieving data with ease. Let's dive right in!

Whether you're a beginner or refreshing your SQL skills, this cheat sheet will provide clear, concise instructions along with practical examples.

SQL Basics: Database Creation and Data Manipulation
To commence, let's explore how to create a database and manipulate data within it.

First, we'll create a new database named 'MyDatabase'.
Creating a New Database

To create a new database, use the following SQL statement:
CREATE DATABASE MyDatabase;
Once the database is created, we can switch to it using the 'USE' command:

USE MyDatabase;
Creating Tables
Next, let's create a table named 'Users'. For this example, we'll include 'id', 'name', and 'email' columns.

The SQL command to create a table is as follows:
CREATE TABLE Users (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL
);




















SQL Basics: Inserting, Updating, Deleting Data
Now that we've created our database and table, let's see how to insert, update, and delete data.
Inserting Data
To add a new user, use the 'INSERT INTO' command:
INSERT INTO Users (name, email)
VALUES ('John Doe', 'john.doe@example.com');
Updating Data
Sometimes, you'll need to update existing data. Here's how to update John Doe's email:
UPDATE Users
SET email = 'new.email@example.com'
WHERE name = 'John Doe';
Deleting Data
Deleting data is straightforward using the 'DELETE' command. Let's remove John Doe:
DELETE FROM Users
WHERE name = 'John Doe';
SQL Basics: Retrieving Data with SELECT
Retrieving data is the most common operation in SQL. Let's fetch all users and their emails.
Basic SELECT Command
Using the 'SELECT' command, we can fetch all columns from the 'Users' table:
SELECT * FROM Users;
SELECT with Conditions
To fetch specific data, add a 'WHERE' clause. Here's how to find users with the name 'Jane':
SELECT * FROM Users
WHERE name = 'Jane';
Now that you've mastered these SQL basics, explore and expand your skills with more advanced topics like joins, subqueries, and aggregate functions. Happy coding!