SQL Statements

সর্বশেষ আপডেট:

Insert Statement:

INSERT INTO table_name (column1, column2)
VALUES ('value1', 'value2');

-- Insert Multiple Row
INSERT INTO table_name (column1, column2)
VALUES
  ('row1_val1', 'row1_val2'),
  ('row2_val1', 'row2_val2');

Select Statement:

-- 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;

মন্তব্য করুন

আপনার ই-মেইল এ্যাড্রেস প্রকাশিত হবে না। * চিহ্নিত বিষয়গুলো আবশ্যক।