-- All Data
SELECT * FROM table_name;
-- Specific Column
SELECT column1, column2 FROM table_name;
-- Limit Rows
-- Get first five rows
SELECT * FROM table_name LIMIT 5;
-- Limit Range (Zero Index Start, Count)
-- Get 6th to 15th rows
SELECT * FROM table_name LIMIT 5, 10;
-- Condition: Exact Match
SELECT * FROM table_name
WHERE column1='value1';
-- Condition: Substring
SELECT * FROM table_name
WHERE column1 LIKE '%value%';
Update Statement:
-- Update a row where id column data is 5
Update table_name
SET column1='val1', column2='val2'
WHERE id=5;
-- Update all rows with same value
-- WHERE clause is omitted
Update table_name
SET column1='val1';
-- Replace text
UPDATE table_name
SET column1 = REPLACE(column1, 'find_text', 'replace_text')
WHERE column1 LIKE ('find_text');
Delete Statement:
-- Delete a row where id column data is 5
DELETE FROM table_name
WHERE id=5;
-- Delete all records
-- WHERE clause is omitted
DELETE FROM table_name;