Sep 8, 2024
SELECT
statement to retrieve data from tables.SELECT * FROM customers;
WHERE
clause for filtering:
SELECT * FROM customers WHERE points > 3000;
ORDER BY
for sorting:
ORDER BY first_name;
INSERT INTO
statement:
INSERT INTO customers (first_name, last_name) VALUES ('John', 'Doe');
INSERT INTO customers (first_name) VALUES ('Alice'), ('Bob');
UPDATE
statement:
UPDATE customers SET points = points + 15 WHERE birth_date < '1990-01-01';
DELETE FROM
statement:
DELETE FROM customers WHERE id = 1;
WHERE
deletes all records.SELECT
, INSERT
, UPDATE
, and DELETE
statements for more complex data retrieval.
UPDATE invoices SET status = 'Paid' WHERE client_id IN (SELECT id FROM clients WHERE name = 'John Doe');
LAST_INSERT_ID()
to get the last insert ID.