Skip to main content

SQL Commands With Example

SQL Commands With Example

SQL Commands With Example
(Image by - Sharma Guides | Subham232330)



ALTER TABLE

ALTER TABLE lets you add columns to a table in a database.

ALTER TABLE table_name ADD column_name datatype;



AND

AND is an operator that combines two conditions. Both conditions must be true for the row to be included in the result set.

SELECT column_name(s) FROM table_name WHERE column_1 = value_1 AND column_2 = value_2;



WITH

WITH clause lets you store the result of a query in a temporary table using an alias. You can also define multiple temporary tables using a comma and with one instance of the WITH keyword.

WITH temporary_name AS (SELECT FROM table_name) SELECT * FROM temporary_name WHERE column_name operator value;



WHERE

WHERE is a clause that indicates you want to filter the result set to include only rows where the following condition is true.

SELECT column_name(s) FROM table_name WHERE column_name operator value;



SELECT DISTINCT

SELECT DISTINCT specifies that the statement is going to be a query that returns unique values in the specified column(s).

SELECT DISTINCT column_name FROM table_name;



SUM

SUM() is a function that takes the name of a column as an argument and returns the sum of all the values in that column.

SELECT SUM(column_name) FROM table_name;



UPDATE

UPDATE statements allow you to edit rows in a table.

UPDATE table_name SET some_column= some_value WHERE some_column= some_value;



SELECT

SELECT statements are used to fetch data from a database. Every query will begin with SELECT.

SELECT column_name FROM table_name;



ROUND()

ROUND() is a function that takes a column name and an integer as an argument. It rounds the values in the column to the number of decimal places specified by the integer.

SELECT ROUND (column_name, integer) FROM table_name;



OUTER JOIN

An outer join will combine rows from different tables even if the join condition is not met. Every row in the left table is returned in the result set, and if the join condition is not met, then NULL values are used to fill in the columns from the right table.

SELECT column_name(s) FROM table_1 LEFT JOIN table_2 ON table_1.column_name = table_2.column_name;



MIN()

MIN() is a function that takes the name of a column as an argument and returns the smallest value in that column.

SELECT MIN(column_name) FROM table_name;



OR

OR is an operator that filters the result set to only include rows where either condition is true.

SELECT column_name FROM table_name WHERE column_name = value_1 OR column_name= value_2;



ORDER BY

ORDER BY is a clause that indicates you want to sort the result set by a particular column either alphabetically or numerically.

SELECT column_name FROM table_name ORDER BY column_name ASC | DESC;



MAX()

MAX() is a function that takes the name of a column as an argument and returns the largest value in that column.

SELECT MAX(column_name) FROM table_name;



INNER JOIN

An inner join will combine rows from different tables if the join condition is true.

SELECT column_name(s) FROM table_1 JOIN table_2 ON table_1.column_name = table_2.column_name;



IS NULL / IS NOT NULL

IS NULL and IS NOT NULL are operators used with the WHERE clause to test for empty values.

SELECT column_name(s) FROM table_name WHERE column_name IS NULL;



Comments

Popular posts from this blog

Networking Interview Questions and Answers

Networking Interview Questions and Answers 1) What is a Network? Answer: The network is defined as a set of devices connected to each other through a physical transmission medium. For example, a computer network is a group of computers connected to each other to communicate and share information and resources such as hardware, data, and software. In a network, nodes are used to connect two or more networks. 2) What is a Node? Answer: Two or more computers are directly connected by fiber optics or any other cable. A node is a point where a connection is established. It is a network component used to send, receive, and forward electronic information. A device connected to a network is also called a Node. Let us consider that in a network there are 2 computers, 2 printers, and a server connected, then we can say that there are five nodes in the network. 3) What is Network Topology? Answer:  Network topology is a physical layout of the computer network and defines how computers,...

Computer Fundamentals in Hindi

Computer Fundamentals in Hindi - कंप्यूटर फंडामेंटल्स हिंदी में - कंप्यूटर का परिचय कंप्यूटर शब्द अंग्रेजी के "Compute" शब्द से बना है, जिसका अर्थ है "गणना", करना होता है इसीलिए इसे गणक या संगणक भी कहा जाता है, इसका अबिस्कर Calculation करने के लिए हुआ था, पुराने समय में Computer का use केवल Calculation करने के लिए किया जाता था किन्तु आजकल इसका use डाक्‍यूमेन्‍ट बनाने, E-Mail, Listening And Viewing Audio And Video, Play Games, Database Preparation के साथ-साथ और कई कामों में किया जा रहा है, जैसे बैकों में, शैक्षणिक संस्‍थानों में, कार्यालयों में, घरों में, दुकानों में, Computer का उपयोग बहुतायत रूप से किया जा रहा है। Computer केवल वह करता है जो हम उसे करने का कहते हैं यानि केवल वह उन Command को फॉलो करता है जो पहले से Computer के अंदर डाले गए होते है, उसके अंदर सोचने समझने की क्षमता नहीं होती है, Computer को जो व्यक्ति चलता है उसे यूजर कहते है, और जो व्यक्ति Computer के लिए Program बनता है उसे Programmer  कहा जाता है। कंप्यूटर को ठीक प्रकार से कार्य करने के लिए सॉफ्टव...

Land Measurements in Bengali

১ কাঠা = ৭২০ বর্গফুট। ১ কাঠা = ৮০ বর্গগজ। ১ কাঠা = ১.৬৫ শতাংশ। ১ কাঠা = ১৬ ছটাক। ২০ কাঠা = ১ বিঘা। ৬০.৫ কাঠা = ১ একর। ========================= ১ একর = ১০০ শতাংশ। ১ একর = ৩ বিঘা ৮ ছটাক। ১ একর = ৬০.৫ কাঠা। ========================= ১ বিঘা = ১৪,৪০০ বর্গফুট। ১ বিঘা = ১৬০০ বর্গগজ। ১ বিঘা = ২০ কাঠা । ১ বিঘা = ৩৩ শতাংশ। ========================= ১ শতাংশ =৪৩৫ বর্গফুট ৬৫.৪৫ বর্গ ইঞ্চি। ১ শতাংশ = ১০০ অযুতাংশ। ৫ শতাংশ = ৩ কাঠা। = ১৩০৬.৮ বর্গফুট । ========================= ১ অযুতাংশ = ৪ বর্গফুট ৫২.৩৬ বর্গ ইঞ্চি। ১ ছটাক = ৪৫ বর্গফুট। ========================= চট্টগ্রামের অধিবাসীদের জন্য নিচের হিসাবটা উপযোগী। ১ কানি = ১৬,৯৯০ বর্গফুট। ১ কানি = ৩৯ শতাংশ। ১ কানি = ২৩.৫ কাঠা। ১ কানি = ২০ গন্ডা। ========================= ১ গন্ডা = ৮৭১ বর্গফুট। ১ গন্ডা = ২ শতাংশ। ১ গন্ডা = ১.২১ কাঠা। ২০ গন্ডা = ১ কানি । ========================= কানিঃ কানি দুই প্রকার। যথা- (ক) কাচ্চা কানি (খ) সাই কানি কাচ্চা কানি : ৪০ শতকে এক বাচ্চা কানি। কাচ্চা কানি ৪০ শতকে হয় বলে একে ৪০ শতকের কানিও বলা হয়। সাই কানিঃ এই কানি কোথাও ১২০...