Category: MySQL Clauses

  • MySQL HAVING Clause

    MySQL HAVING Clause is used with GROUP BY clause. It always returns the rows where condition is TRUE. Syntax: Parameters aggregate_function: It specifies any one of the aggregate function such as SUM, COUNT, MIN, MAX, or AVG. expression1, expression2, … expression_n: It specifies the expressions that are not encapsulated within an aggregate function and must be included…

  • MySQL GROUP BY Clause

    The MYSQL GROUP BY Clause is used to collect data from multiple records and group the result by one or more column. It is generally used in a SELECT statement. You can also use some aggregate functions like COUNT, SUM, MIN, MAX, AVG etc. on the grouped column. Syntax: Parameters expression1, expression2, … expression_n: It specifies…

  • MySQL ORDER BY Clause

    The MYSQL ORDER BY Clause is used to sort the records in ascending or descending order. Syntax: Parameters expressions: It specifies the columns that you want to retrieve. tables: It specifies the tables, from where you want to retrieve records. There must be at least one table listed in the FROM clause. WHERE conditions: It is optional. It…

  • MySQL FROM Clause

    The MySQL FROM Clause is used to select some records from a table. It can also be used to retrieve records from multiple tables using JOIN condition. Syntax: Parameters table1 and table2: specify tables used in the MySQL statement. The two tables are joined based on table1.column1 = table2.column1. Note: MySQL FROM Clause: Retrieve data from…

  • MySQL Distinct Clause

    MySQL DISTINCT clause is used to remove duplicate records from the table and fetch only the unique records. The DISTINCT clause is only used with the SELECT statement. Syntax: Parameters expressions: specify the columns or calculations that you want to retrieve. tables: specify the name of the tables from where you retrieve records. There must be at…

  • MySQL WHERE Clause

    MySQL WHERE Clause is used with SELECT, INSERT, UPDATE and DELETE clause to filter the results. It specifies a specific position where you have to do the operation. Syntax: Parameter: conditions: It specifies the conditions that must be fulfilled for records to be selected. MySQL WHERE Clause with single condition Let’s take an example to…