To find a data line of work in 2023, you will have to learn SQL. Similarly, as with any language and particularly when you are a fledgling, it very well may be valuable to have a rundown of normal SQL orders and administrators in a single spot to allude to at whatever point you want it — we might want to be that spot for you!
The following is a complete rundown of SQL orders, coordinated by the high level of each (for example SELECT TOP is inside the SELECT class) in Top SQL Commands
In the event that you're on an excursion to learn SQL and you've been baffled by the absence of design or the dull educational plan made out of Google look, then, at that point, you might like Dataquest's intuitive SQL courses. Whether you're a novice attempting to prepare work or a carefully prepared engineer hoping to remain sharp, there's a SQL course for you.
SELECT is probably the most commonly-used SQL statement. You’ll use it pretty much every time you query data with SQL. It allows you to define what data you want your query to return.
For example, in the code below, we’re selecting a column called name from a table called customers.
SELECT name
FROM customers;
SELECT used with an asterisk (*) will return all of the columns in the table we’re querying.
SELECT * FROM customers;
SELECT DISTINCT only returns data that is distinct — in other words, if there are duplicate records, it will return only one copy of each.
The code below would return only rows with a unique name from the customer's table.
SELECT DISTINCT name
FROM customers;
SELECT INTO copies the specified data from one table into another.
SELECT * INTO customers
FROM customers_backup;
SELECT TOP only returns the top x number or percent from a table.
The code below would return the top 50 results from the customer's table:
SELECT TOP 50 * FROM customers;
The code below would return the top 50 percent of the customer's table:
SELECT TOP 50 PERCENT * FROM customers;
AS renames a column or table with an alias that we can choose. For example, in the code below, we’re renaming the name column as first_name:
SELECT name AS first_name
FROM customers;
FROM specifies the table we’re pulling our data from:
SELECT name
FROM customers;
WHERE filters your query to only return results that match a set condition. We can use this together with conditional operators like =, >, <, >=, <=, etc.
SELECT name
FROM customers
WHERE name = ‘Bob’;
AND combines two or more conditions in a single query. All of the conditions must be met for the result to be returned.
SELECT name
FROM customers
WHERE name = ‘Bob’ AND age = 55;
OR combines two or more conditions in a single query. Only one of the conditions must be met for a result to be returned.
SELECT name
FROM customers
WHERE name = ‘Bob’ OR age = 55;
BETWEEN filters your query to return only results that fit a specified range.
SELECT name
FROM customers
WHERE age BETWEEN 45 AND 55;
LIKE searches for a specified pattern in a column. In the example code below, any row with a name that included the character Bob would be returned.
SELECT name
FROM customers
WHERE name LIKE ‘%Bob%’;
Other operators for LIKE:
IN allows us to specify multiple values we want to select when using the WHERE command.
SELECT name
FROM customers
WHERE name IN (‘Bob’, ‘Fred’, ‘Harry’);
IS NULL will return only rows with a NULL value.
SELECT name
FROM customers
WHERE name IS NULL;
IS NOT NULL does the opposite — it will return only rows without a NULL value.
SELECT name
FROM customers
WHERE name IS NOT NULL;
CREATE can be used to set up a database, table, index, or view.
CREATE DATABASE creates a new database, assuming the user running the command has the correct admin rights.
CREATE DATABASE dataquestDB;
CREATE TABLE creates a new table inside a database. The terms int and varchar(255) in this example specify the datatypes of the columns we’re creating.
CREATE TABLE customers (
customer_id int,
name varchar(255),
age int
);
CREATE INDEX generates an index for a table. Indexes are used to retrieve data from a database faster.
CREATE INDEX idx_name
ON customers (name);
CREATE VIEW creates a virtual table based on the result set of an SQL statement. A view is like a regular table (and can be queried like one), but it is not saved as a permanent table in the database.
CREATE VIEW [Bob Customers] AS
SELECT name, age
FROM customers
WHERE name = ‘Bob’;
DROP statements can be used to delete entire databases, tables, or indexes.
It goes without saying that the DROP command should only be used where absolutely necessary.
DROP DATABASE deletes the entire database including all of its tables, indexes, etc as well as all the data within it.
Again, this is a command we want to be very, very careful about using!
DROP DATABASE dataquestDB;
DROP TABLE deletes a table as well as the data within it.
DROP TABLE customers;
DROP INDEX deletes an index within a database.
DROP INDEX idx_name;
The UPDATE statement is used to update data in a table. For example, the code below would update the age of any customer named Bob in the customer's table to 56.
UPDATE customers
SET age = 56
WHERE name = ‘Bob’;
DELETE can remove all rows from a table (using ), or can be used as part of a WHERE clause to delete rows that meet a specific condition.
DELETE FROM customers
WHERE name = ‘Bob’;
ALTER TABLE allows you to add or remove columns from a table. In the code snippets below, we’ll add and then remove a column for a surname. The text varchar(255) specifies the datatype of the column.
ALTER TABLE customers
ADD surname varchar(255);
ALTER TABLE customers
DROP COLUMN surname;
That's all. These all are the basic SQL Commands
Also, Read What is Figma Ui UX Design and Why Does it Matter?