MySQL JOINS

MySQL JOINS MySQL JOINS are used with SELECT statement. It is used to retrieve data from multiple tables. It is performed whenever you need to fetch records from two or more tables. There are three types of MySQL joins: MySQL INNER JOIN (“or sometimes called simple join”) MySQL LEFT OUTER JOIN (“or sometimes called LEFT … Read more

MySQL Conditions

MySQL AND Condition The MySQL AND condition is used with SELECT, INSERT, UPDATE or DELETE statements to test two or more conditions in an individual query. Syntax: WHERE condition1 AND condition2 … AND condition_n; Parameter explanation: condition1, condition2, … condition_n: Specifies all conditions that must be fulfilled for the records to be selected. MySQL AND Example The following … Read more

MySQL HAVING Clause

MySQL HAVING Clause MySQL HAVING Clause is used with GROUP BY clause. It always returns the rows where condition is TRUE. Syntax: SELECT expression1, expression2, … expression_n, aggregate_function (expression) FROM tables [WHERE conditions] GROUP BY expression1, expression2, … expression_n HAVING condition; 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 … Read more

Categories bca

MySQL GROUP BY Clause

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: SELECT expression1, expression2, … expression_n, aggregate_function (expression) … Read more

MySQL ORDER BY Clause

MySQL ORDER BY Clause The MYSQL ORDER BY Clause is used to sort the records in ascending or descending order. Syntax: SELECT expressions FROM tables [WHERE conditions] ORDER BY expression [ ASC | DESC ]; 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 … Read more

MySQL FROM Clause

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: FROM table1 [ { INNER JOIN | LEFT [OUTER] JOIN| RIGHT [OUTER] JOIN } table2 ON table1.column1 = table2.column1 ] Parameters table1 and table2: specify tables used in the MySQL statement. The two tables are joined based on table1.column1 = table2.column1. … Read more

MySQL Distinct Clause

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: SELECT DISTINCT expressions FROM tables [WHERE conditions]; Parameters expressions: specify the columns or calculations that you want to retrieve. tables: specify the name of the tables from … Read more

MySQL WHERE Clause

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: WHERE conditions; Parameter: conditions: It specifies the conditions that must be fulfilled for records to be selected. MySQL WHERE Clause with single condition Let’s … Read more

MySQL SELECT Statement

MySQL SELECT Statement The MySQL SELECT statement is used to fetch data from the one or more tables in MySQL. We can retrieve records of all fields or specified fields. Syntax for specified fields: SELECT expressions FROM tables [WHERE conditions]; Syntax for all fields: SELECT * FROM tables [WHERE conditions]; MySQL SELECT Example 1: for specified fields In such case, it is mandatory … Read more

MySQL DELETE Statement

MySQL DELETE Statement MySQL DELETE statement is used to delete data from the MySQL table within the database. By using delete statement, we can delete records on the basis of conditions. Syntax: DELETE FROM table_name WHERE (Condition specified); Example: DELETE FROM cus_tbl WHERE cus_id = 6; Output: