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:

MySQL UPDATE Query

MySQL UPDATE Query MySQL UPDATE statement is used to update data of the MySQL table within the database. In real life scenario, records are changed over the period of time. So, we need to make changes in the values of the tables also. To do so, we need to use the UPDATE statement. The UPDATE … Read more

MySQL INSERT Statement

MySQL INSERT Statement MySQL INSERT statement is used to insert data in MySQL table within the database. We can insert single or multiple records using a single query in MySQL. Syntax: The SQL INSERT INTO command is used to insert data in MySQL table. Following is a generic syntax: INSERT INTO table_name ( field1, field2,…fieldN ) VALUES ( value1, value2,…valueN ); Syntax for all … Read more

MySQL View

MySQL View In MySQL, View is a virtual table created by a query by joining one or more tables. MySQL Create VIEW A VIEW is created by SELECT statements. SELECT statements are used to take data from the source table to make a VIEW. Syntax: CREATE [OR REPLACE] VIEW view_name AS SELECT columns FROM tables [WHERE conditions]; Parameters: OR REPLACE: It is optional. … Read more

MySQL DROP Table

MySQL DROP Table MYSQL DROP table statement removes the complete data with structure. Syntax: DROP TABLE  table_name; Example: DROP TABLE  cus_tbl; MySQL TRUNCATE Table vs DROP Table You can also use DROP TABLE command to delete complete table but it will remove complete table data and structure both. You need to re-create the table again if you have to … Read more