Top common SQL statements that are still in use in 2023

0

Here are examples of each of the SQL statements:

SELECT:

SELECT column1, column2, column3 FROM table_name;
This statement retrieves data from the columns "column1", "column2", and "column3" in the table "table_name".

INSERT:

INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);
This statement inserts a new row into the table "table_name", with values "value1", "value2", and "value3" for the columns "column1", "column2", and "column3", respectively.

UPDATE:

UPDATE table_name SET column1 = value1, column2 = value2 WHERE some_column = some_value;
This statement modifies existing data in the table "table_name", setting the value of "column1" to "value1" and "column2" to "value2" where the value of "some_column" is "some_value". 

DELETE:

DELETE FROM table_name WHERE some_column = some_value;
    This statement deletes rows from the table "table_name" where the value of "some_column" is "some_value".

ALTER:

ALTER TABLE table_name ADD column4 datatype;
This statement adds a new column "column4" with data type "datatype" to the table "table_name".

CREATE:

CREATE TABLE table_name (column1 datatype, column2 datatype, column3 datatype);
This statement creates a new table called "table_name" with columns "column1", "column2", and "column3" of data types "datatype", "datatype", and "datatype" respectively.

DROP:

DROP TABLE table_name;
This statement deletes the table "table_name" and all its data permanently.

JOIN:

SELECT * FROM table1 JOIN table2 ON table1.column = table2.column;
This statement retrieves all data from both tables "table1" and "table2" and combines the rows where the value of "table1.column" is equal to "table2.column".

WHERE:

SELECT column1, column2 FROM table_name WHERE column3 > some_value;
This statement retrieves data from the columns "column1" and "column2" in the table "table_name" where the value of "column3" is greater than "some_value".

GROUP BY:

SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;
This statement retrieves data from the "column1" and groups it by "column1", also it counts the number of occurrences of the value of "column2" in each group.


This is just an example and the actual syntax and usage might vary depending on the specific SQL database system you are using.
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

Random Posts