MySQL + SQL · Lesson 122

MySQL Cheat Sheet

Quick Reference

All the most-used SQL in one place for fast revision.

DDL & DML

CREATE TABLE t (id INT PRIMARY KEY, name VARCHAR(50));
ALTER TABLE t ADD age INT;
DROP TABLE t;
INSERT INTO t VALUES (1, 'Aman');
UPDATE t SET name='Riya' WHERE id=1;
DELETE FROM t WHERE id=1;

Querying

SELECT col1, col2 FROM t WHERE cond ORDER BY col1 DESC LIMIT 10;
SELECT class, COUNT(*) FROM students GROUP BY class HAVING COUNT(*)>5;
SELECT a.x, b.y FROM a JOIN b ON a.id=b.a_id;

Summary

  • DDL: CREATE/ALTER/DROP; DML: INSERT/UPDATE/DELETE.
  • Query: SELECT ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... LIMIT, plus JOIN.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp