Author: Awais Farooq
-
SELECT IN
SQL IN is an operator used in a SQL query to help reduce the need to use multiple SQL “OR” conditions. It is used in SELECT, INSERT, UPDATE or DELETE statement. Advantage of SQL SELECT IN It minimizes the use of SQL OR operator. Let’s see the syntax for SQL IN: Take an example with…
-
SELECT RANDOM
The SQL SELECT RANDOM() function returns the random row. It can be used in online exam to display the random questions. There are a lot of ways to select a random record or row from a database table. Each database server needs different SQL syntax. If you want to select a random row with MY SQL:…
-
SELECT LAST
The LAST() function in Structured Query Language shows the last value from the specified column of the table. Note: This SQL function is only supported in Microsoft Access database. Oracle supports ORDER BY and ROWNUM keywords, and MySQL supports the LIMIT keyword for selecting the last record. Syntax of LAST() Function In the above syntax, the LAST…
-
SELECT FIRST
The SQL first() function is used to return the first value of the selected column. Let’s see the syntax of sql select first() function: Here a point is notable that first function is only supported by MS Access. If you want to retrieve the first value of the “customer_name” column from the “customers” table, you…
-
SELECT TOP
The SELECT TOP statement in SQL shows the limited number of records or rows from the database table. The TOP clause in the statement specifies how many rows are returned. It shows the top N number of rows from the tables in the output. This clause is used when there are thousands of records stored in the…
-
SELECT COUNT
The SQL COUNT() is a function that returns the number of records of the table in the output. This function is used with the SQL SELECT statement. Let’s take a simple example: If you have a record of the voters in the selected area and want to count the number of voters, then it is very difficult to…
-
SELECT DISTINCT
The SQL DISTINCT command is used with SELECT key word to retrieve only distinct or unique data. In a table, there may be a chance to exist a duplicate value and sometimes we want to retrieve only unique values. In such scenarios, SQL SELECT DISTINCT statement is used. Note: SQL SELECT UNIQUE and SQL SELECT DISTINCT statements…
-
SELECT UNIQUE
Actually, there is no difference between DISTINCT and UNIQUE. SELECT UNIQUE is an old syntax which was used in oracle description but later ANSI standard defines DISTINCT as the official keyword. After that oracle also added DISTINCT but did not withdraw the service of UNIQUE keyword for the sake of backward compatibility. In simple words, we…
-
SELECT Statement
The SELECT statement is the most commonly used command in Structured Query Language. It is used to access the records from one or more database tables and views. It also retrieves the selected data that follow the conditions we want. By using this command, we can also access the particular record from the particular column…
-
ALTER TABLE
The ALTER TABLE statement in Structured Query Language allows you to add, modify, and delete columns of an existing table. This statement also allows database users to add and remove various SQL constraints on the existing tables. Any user can also change the name of the table using this statement. ALTER TABLE ADD Column statement…