0% found this document useful (0 votes)
7 views2 pages

SRETE

The document provides an overview of MySQL basics, including data types such as INT, VARCHAR, DATE, and FLOAT. It outlines SQL language categories (DDL, DML, DCL, TCL) and common SQL commands for creating, inserting, reading, updating, and deleting records. Additionally, it explains SQL joins and filtering, grouping, and aggregation functions with examples.

Uploaded by

aravindgb11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

SRETE

The document provides an overview of MySQL basics, including data types such as INT, VARCHAR, DATE, and FLOAT. It outlines SQL language categories (DDL, DML, DCL, TCL) and common SQL commands for creating, inserting, reading, updating, and deleting records. Additionally, it explains SQL joins and filtering, grouping, and aggregation functions with examples.

Uploaded by

aravindgb11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MYSQL BASICS

1. Data Types

Type Description Example

INT Integer values id INT 1,2,3 Etc without decimal

VARCHAR String values name VARCHAR(50) :'Hello World'

DATE Date format dob DATE :1999-12-31

FLOAT Decimal values salary FLOAT: 123.456789

2. SQL Language Categories

Type Full Form Used For

DDL Data Definition Language Create/modify tables

DML Data Manipulation Language Insert/update/delete data

DCL Data Control Language Grant/revoke permissions

TCL Transaction Control Language Commit/rollback changes

3. Common SQL Commands

-- Create table

CREATE TABLE employees (id INT, name VARCHAR(50));

-- Insert record

INSERT INTO employees VALUES (1, 'Aravind');

-- Read data

SELECT * FROM employees;

-- Update data

UPDATE employees SET name = 'Kumar' WHERE id = 1;

-- Delete record

DELETE FROM employees WHERE id = 1;


4. SQL Joins with Examples

Join Type Description Example

Only matching
INNER sql\nSELECT [Link], [Link] FROM employees e INNER JOIN
rows from both
JOIN departments d ON e.dept_id = [Link];\n
tables

All rows from left


sql\nSELECT [Link], [Link] FROM employees e LEFT JOIN
LEFT JOIN + matches from
departments d ON e.dept_id = [Link];\n
right

All rows from


RIGHT sql\nSELECT [Link], [Link] FROM employees e RIGHT JOIN
right + matches
JOIN departments d ON e.dept_id = [Link];\n
from left

sql\nSELECT * FROM employees LEFT JOIN departments ON


FULL JOIN
All records from employees.dept_id = [Link]\nUNION\nSELECT * FROM
(via
both sides employees RIGHT JOIN departments ON employees.dept_id =
UNION)
[Link];\n

5. Filtering, Grouping, Aggregation

-- WHERE

SELECT * FROM employees WHERE salary > 40000;

-- GROUP BY

SELECT dept, COUNT(*) FROM employees GROUP BY dept;

-- HAVING

SELECT dept, AVG(salary) FROM employees GROUP BY dept HAVING AVG(salary) > 50000;

Function Purpose Example

COUNT() Total count SELECT COUNT(*) FROM employees;

AVG() Average value SELECT AVG(salary) FROM employees;

SUM() Total sum SELECT SUM(salary) FROM employees;

MAX() Highest value SELECT MAX(salary) FROM employees;

MIN() Lowest value SELECT MIN(salary) FROM employees;

You might also like