SQL Update – SQL TUTORIAL | Software Testing Material

SQL Update Query: The SQL UPDATE statement is used to update records in a table. SQL UPDATE Query Syntax: UPDATE table_name SET column_1=value_1,column_2=value_2,…column_n=value_n WHERE some_column=some_value; 1 UPDATE table_name SET column_1=value_1,column_2=value_2,…column_n=value_n WHERE some_column=some_value; Here the WHERE clause specifies which record should be updated. If we didn’t mention WHERE clause then all the records will be updated. Example: Following statement would update…

SQL Insert Query – SQL TUTORIAL | Software Testing Material

SQL Insert Query: The SQL INSERT INTO statement is used to insert new records in a table. Syntax: INSERT INTO table_name (column_name_1,column_name_2,column_name_3,… column_name_n) VALUES (value_1,value_2,value_3,…value_n); 1 INSERT INTO table_name (column_name_1,column_name_2,column_name_3,… column_name_n) VALUES (value_1,value_2,value_3,…value_n); Here, column_name_1, column_name_2,…column_name_N are the names of the columns in the table into which you want to insert data. Example: Following statements would create…

SQL AND OR Operators – SQL TUTORIAL | Software Testing Material

SQL AND OR Operators: In this post, we will see both SQL AND OR Operators in detail. SQL AND Operator: It fetches the records only if both the first and the second condition are true. Syntax: SELECT * FROM table_name WHERE column_name_1=somevalue AND column_name_2=somevalue; 1 SELECT * FROM table_name WHERE column_name_1=somevalue AND column_name_2=somevalue; Example: SELECT * FROM SCOREBOARD WHERE…

SQL BETWEEN Operator – SQL TUTORIAL | Software Testing Material

SQL BETWEEN Operator: SQL BETWEEN operator selects values within a range. The values can be numbers, text, or dates. SQL BETWEEN Syntax: SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value_1 AND value_2; 1 SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value_1 AND value_2; SQL BETWEEN Example: SELECT * FROM SCOREBOARD WHERE Runs BETWEEN 90 AND 100;SELECT * FROM SCOREBOARD WHERE…

SQL IN Operator – SQL TUTORIAL | Software Testing Material

SQL IN Operator: The SQL IN operator allows you to test if an expression matches any value in a list of values. It is specified with in a WHERE clause. Syntax: SELECT column_name(s) FROM table_name WHERE column_name IN (value_1,value_2,…value_n); 1 SELECT column_name(s) FROM table_name WHERE column_name IN (value_1,value_2,…value_n); Example: SELECT * FROM SCOREBOARD WHERE Runs IN (100,90); 1 SELECT *…

SQL LIKE Operator – SQL TUTORIAL | Software Testing Material

SQL LIKE Operator: The SQL LIKE operator is used in a WHERE clause to compare a value to similar values using wildcard operators. There are two wildcard operators used in conjunction with the Like operator. Percentage sign ( % ) Underscore sign ( _ ) SQL LIKE Syntax: SELECT column_name(s) FROM table_name WHERE column_name LIKE somevalue; 1 SELECT column_name(s) FROM table_name WHERE column_name LIKE…

SQL HAVING – SQL Tutorial | Software Testing Material

SQL Having: While using aggregate functions, we couldn’t use WHERE clause. We need to use SQL HAVING clause while using aggregate functions. The HAVING Clause places conditions on Groups created by the GROUP BY clause where as the WHERE Clause places conditions on the selected columns. Syntax: SELECT column_name(s)FROM table_nameWHERE conditionGROUP BY column_name(s)HAVING conditionORDER BY…

SQL GROUP BY – SQL Tutorial | Software Testing Material

SQL Group By: The SQL GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns. Syntax: SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name(s); 1 SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name(s); Example:…

SQL ORDER BY keyword – SQL TUTORIAL | Software Testing Material

SQL ORDER BY keyword: SQL ORDER BY keyword is used to sort the data in ascending or descending order, based on one or more columns. Syntax: SELECT column_name_1, column_name_2 FROM table_name ORDER BY column_name_1 ASC|DESC, column_name_2 ASC|DESC; 1 SELECT column_name_1, column_name_2 FROM table_name ORDER BY column_name_1 ASC|DESC, column_name_2 ASC|DESC; Example: Order By – Ascending Order: SELECT * FROM SCOREBOARD ORDER BY…

SQL UNION CLAUSE AND UNION ALL CLAUSE – SQL TUTORIAL

SQL UNION Clause: SQL UNION operator combines the result of two or more SELECT statements. The SQL UNION operator selects only distinct values by default. Syntax: SELECT * FROM Table_Name1 UNION SELECT * FROM Table_Name2; 1 SELECT * FROM Table_Name1 UNION SELECT * FROM Table_Name2; Example: SELECT * FROM PLAYERSUNIONSELECT * FROM SCOREBOARD 1 2…