0% found this document useful (0 votes)
0 views

MySQL_Syntax_Cheat_Sheet

This document is a MySQL syntax cheat sheet that provides a quick reference for various SQL commands. It includes commands for creating tables, inserting data, retrieving data, filtering results, and modifying records, along with examples for each command. The cheat sheet also covers advanced concepts like joins, grouping, and limiting results.

Uploaded by

Ranvijay maurya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

MySQL_Syntax_Cheat_Sheet

This document is a MySQL syntax cheat sheet that provides a quick reference for various SQL commands. It includes commands for creating tables, inserting data, retrieving data, filtering results, and modifying records, along with examples for each command. The cheat sheet also covers advanced concepts like joins, grouping, and limiting results.

Uploaded by

Ranvijay maurya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MySQL Syntax Cheat Sheet

Command Use Example

CREATE TABLE Create a new table CREATE TABLE emp (id INT, name VARCHAR(100));

INSERT INTO Insert new data into a table INSERT INTO emp (id, name) VALUES (1, 'John');

SELECT Retrieve data from a table SELECT name FROM emp;

WHERE Filter data based on condition SELECT * FROM emp WHERE id = 1;

AND / OR / NOT Combine conditions SELECT * FROM emp WHERE id = 1 AND name='John';

ORDER BY Sort the result SELECT * FROM emp ORDER BY id DESC;

GROUP BY Group rows and use aggregate functions


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

HAVING Filter groups (used with GROUP BY) SELECT dept, COUNT(*) FROM emp GROUP BY dept HAV

UPDATE Modify existing records UPDATE emp SET name = 'Raj' WHERE id = 1;

DELETE Remove records from table DELETE FROM emp WHERE id = 1;

JOIN Combine data from multiple tables SELECT e.name, d.loc FROM emp e JOIN dept d ON e.did =

LIKE Pattern matching SELECT * FROM emp WHERE name LIKE 'A%';

IN Match multiple values SELECT * FROM emp WHERE dept IN ('HR', 'Sales');

BETWEEN Range-based filtering SELECT * FROM emp WHERE salary BETWEEN 30000 AN

DISTINCT Remove duplicates SELECT DISTINCT dept FROM emp;

LIMIT Limit number of results SELECT * FROM emp LIMIT 10;

Page 1

You might also like