Category: 03. SQL Select

  • SELECT NULL

    First of all we should know that what null value is? Null values are used to represent missing unknown data. There can be two conditions: If in a table, a column is optional, it is very easy to insert data in column or update an existing record without adding a value in this column. This…

  • SELECT SUM

    It is also known as SQL SUM() function. It is used in a SQL query to return summed value of an expression. Let’s see the Syntax for the select sum function: expression may be numeric field or formula. This would produce the following result. ID EMPLOYEE_NAME SALARY 1 JACK REACHER 32000 2 PADMA MAHESHWARI 22000…

  • SELECT DATE

    SQL SELECT DATE is used to retrieve a date from a database. If you want to find a particular date from a database, you can use this statement. For example: let’s see the query to get all the records after ‘2013-12-12’. Let’s see the another query to get all the records after ‘2013-12-12’ and before ‘2013-12-13’…

  • SELECT from Multiple Tables

    This statement is used to retrieve fields from multiple tables. To do so, we need to use join query to get data from multiple tables. Let’s see the example for the select from multiple tables: Let us take three tables, two tables of customers named customer1 and customer2 and the third table is product table.…

  • 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…