SQL Syntax

SELECT Statement:

Used to retrieves data from tables.

                                                    
                                                    SELECT column1, column2 FROM table_name WHERE condition;
                                                    
                                                

INSERT Statement:

Used to add a new data to a table.

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

UPDATE Statement:

Used to modifies existing records in a table.

                                                    
                                                    UPDATE table_name SET column1 = value1 WHERE condition;
                                                    
                                                

DELETE Statement:

Used to removes records from a table.

                                                    
                                                    DELETE FROM table WHERE condition;
                                                    
                                                

CREATE TABLE Statement:

Used to defines a new table structure.

                                                    
                                                    CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    PRIMARY KEY (column1)
);
                                                    
                                                

ALTER TABLE Statement:

Alter you can use modifies an existing table (e.g., adds a new column).

                                                    
                                                    ALTER TABLE table_name
ADD column_name datatype;
                                                    
                                                

DROP TABLE Statement:

Used to delete an existing table.

                                                    
                                                    DROP TABLE table_name;
                                                    
                                                

JOIN Clause Statement:

Used to combines rows from two or more tables based on a related column.

                                                    
                                                    SELECT *
FROM table1
INNER JOIN table2 ON table1.column = table2.column;
                                                    
                                                

GROUP BY Clause Statement:

Used to groups rows that have the same values in specified columns.

                                                    
                                                    SELECT column, COUNT(*)
FROM table
GROUP BY column;
                                                    
                                                

ORDER BY Clause Statement:

Used to Sorts the result set based on one or more columns.

                                                    
                                                    SELECT column1, column2
FROM table
ORDER BY column1 ASC, column2 DESC;
                                                    
                                                

WHERE Clause Statement:

Used to filters the rows based on a specified condition.

                                                    
                                                    SELECT column1, column2
FROM table
WHERE condition;
                                                    
                                                

AND, OR, Statement:

Used to Combine multiple conditions in WHERE clauses.

                                                    
                                                    SELECT column1, column2
FROM table
WHERE condition1 AND condition2;
                                                    
                                                

LIKE Statement:

Used to searches for a specified pattern in a column.

                                                    
                                                    SELECT column1
FROM table
WHERE column1 LIKE 'pattern%';
                                                    
                                                

IN Statement:

Used to Specifies multiple values for a WHERE clause.

                                                    
                                                    SELECT column1
FROM table
WHERE column1 IN (value1, value2, ...);