Posts From askiguru

How to use a Where Clause in SQL?

While fetching or retrieving the data from a single table or with multiple tables, the SQL WHERE clause is used. In order to return value from the table, the given condition should be fulfilled. Where Clause is used to sort the data and retrieve only the necessary records. The Where Clause is not only used in combination with Select Statement, but also with the Update Statement, Delete Statement and so on.  

How to update a table using SQL Update?

To make any changes in the existing data of the table, SQL UPDATE Query is used. Combine UPDATE Query with the WHERE Clause to modify selected records, otherwise all the data records will be affected.   Syntax: The UPDATE Query Syntax is as follows: UPDATE table_name Set column1 = value1, column2 = value2, ……, columnN = valueN WHERE condition;   You can combine N number of conditions using AND or

How to Truncate a Table in SQL?

In order to delete or empty the entire data from a particular existing table, the SQL TRUNCATE TABLE command is used. The difference between the Drop Table and Truncate Table is that, when you use Drop Table statement the entire table structure along with its data gets deleted, Wherein when you use Truncate Table Statement, the entire data gets deleted retaining the table structure.   The syntax of TRUNCATE TABLE is: Truncate Table table_name;

What are the different SQL Syntax?

SQL is defined by distinctive set of rules and guidelines called Syntax. There can be one or more than one tables in a single database. Each table is indentified by a unique name (e.g. “Employees” or “students”). Each table contains various records (rows) and fields (columns) with respective data.   SQL Statements Most of the actions you need to perform on a database are done with SQL statements. The important

How to select a single Database in SQL?

In order to select a single database from the multiple databases in your SQL Schema and to start your operation, make use of the SQL USE Statement. The USE statement is used to select any existing dataset from the list of databases.   Basic syntax of USE statement is as follows: USE DatabaseName; Kindly note that the Database Name should always be unique in RDBMS.   Example: Check the list

How to write a Select Statement in SQL?

In order to fetch or retrieve data from a table and display the data in the form of resultant table, SQL Select Statement is used. The resultant tables are known as result-sets.   Syntax: The syntax of SELECT statement is: Select column_name1, column_name2, …, column_namen From table_name; And it can also be written as follows:   Select * From table_name;   In the above syntax, column_name1, column_name2 are the fields

How to use a Primary Key in SQL?

The PRIMARY KEY is a set of columns that uniquely identifies each record in a database table. Primary keys must contain unique values and cannot contain NULL values. Most tables should have a primary key, and each table can have only ONE primary key. SQL PRIMARY KEY Constraint on CREATE TABLE The following SQL creates a PRIMARY KEY on the "roll_no" column when the "Students" table is created:   Create

How to use an Order-By Clause in SQL?

In order to sort the result-set of many columns in ascending or descending order, the SQL ORDER BY clause is used.   The records are by default sort in ascending order when used ORDER BY keyword. To sort the data in the descending order, make use of the DESC keyword.   By sorting the data, make sure that the column you want to sort is present in that respective column-list.   The

What are different types of SQL Operators?

What is an Operator in SQL? An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. ·         Arithmetic operators ·         Comparison operators ·         Logical operators ·         Operators used to negate conditions   SQL

What is a Null Value in SQL?

In order to represent a missing or unknown value, the SQL NULL is the term used. A NULL value is a value in a table where a column (field) that appears to be blank. By default, the table takes NULL values. It is essential to identify that a NULL value is different than a zero value or a field that contains spaces. Let us now understand the IS NULL and IS NOT