Wear a mask
Maintain Social Distancing
Stay at Home
Sanitize yourself
Get your Vaccination Done.
The Insert Into Select statement
The INSERT INTO SELECT statement copies data from one table and inserts it into another table. This statement requires that the data types in source and target tables matches. The existing records in the target table are unaffected. SYNTAX One can also copy only the names of the specific columns that he she wants inโฆ
EXISTS, ANY, ALL
EXISTS: The EXISTS operator is used to check the existence of record in the subquery. It returns TRUE if the subquery returns one or more records. SYNTAX: ANY & ALL : These operators allow you to perform a comparison between a single column value and a range of other values. ANY operator: returns a Boolean valueโฆ
GROUP BY & HAVING
GROUP BY The GROUP BY statement groups rows that have the same values into summary rows. This statement is often used with aggregate functions like COUNT(), MAX() , MIN() , SUM() , AVG() to group the result-set by one or more columns. Syntax: HAVING The HAVING clause was added to SQL because the WHERE keywordโฆ
UNION
The MySQL UNION operator is used to combine the result-set of two or moreย SELECTย statements. To apply the UNION operator one must remember following things: Everyย SELECTย statement withinย UNIONย must have the same number of columns The columns must also have similar data types The columns in everyย SELECTย statement must also be in the same order Syntax: To allow theโฆ
JOINS
The JOIN clause is used to combine rows from two or more tables, based on a related column between them. JOINS are of five types. INNER JOIN LEFT JOIN RIGHT JOIN CROSS JOIN SELF JOIN INNER JOIN The INNER JOIN keyword selects records that have matching values in both tables. Syntax: LEFT JOIN The LEFTโฆ
Column Aliases
The column that you select in a query can be given a different name i.e. column alias name for output purposes. For instance consider a table named school and it has a column class, so the name of the column class can be changed to any other name like Standard and can be displayed asโฆ
SUM, AVG & COUNT
SUM SUM() is used to calculate the total numeric sum of a column, i.e. all the numeric values will be added and will be displayed as result. SYNTAX EXAMPLE AVG AVG() returns the average of the numeric values of a specific column. SYNTAX EXAMPLE COUNT COUNT() returns the number of rows that matches a specifiedโฆ
MAX, MIN & LIMIT
MAX() is used to find out the maximum value of a selected column. Where as MN() is used to find the minimum value. The use of both max and min is very simple in MYSQL, even a child can learn to use it! SYNTAX: MAX() : MIN(): Example LIMIT This clause is used to specifyโฆ
DELETE , ALTER & DROP Command
DELETE While working with tables, one may reach a situation where he/she no longer needs some rows of data. In such a case one would like to remove such rows. This can be done by using the DELETE command. The DELETE command removes rows from a table. This removes the entire rows, not individual fieldโฆ
UPDATE Table
UPDATE Sometimes one needs to change some or all the values in a particular row that is already existing. This can be done using the UPDATE command. It specifies the rows to be changed using the WHERE clause, and the new data using the SET keyword. The new data can be a specified constant, anโฆ
Handling NULLS
The empty values are represented as NULLS in a table. If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value. A NULL value is different from ZERO. NULLโฆ
ORDER BY Clause
Whenever a SELECT query is executed, the resulting rows emerge in a pre-decided order. One can sort the results or a query in a specific order using the ‘ORDER BY’ clause. The ORDER BY clause allows string of query results by one or more columns. The sorting can be done either in ascending order orโฆ
AND , OR & NOT
AND, OR & NOT are used when the conditions for selecting an entry are more specific. These keywords are used along with WHERE. They are the logical operators. They can also be used with these symbols. AND (&&) OR (||) NOT (!) Syntax: Examples
The WHERE Clause
Sometimes a table may contain a huge number of rows, so when the user wants to see a particular row or a particular data and selects all the rows , then it will be problematic as it takes longer time to find out that particular information from such a big table, So in order toโฆ
Select Query
The select query is used to display the contents of the table. It can either be used to display the entire table, specific columns, columns with some particular values or specific cases. The different ways in which select can be used are as follows: 1 . Select * It is used to select all theโฆ
Show Databases, Show Tables and Desc Table Queries
Show databases: It is used to display the list of all the databases in your MySQL. It is used in the following manner. Show Tables: It is display the of all the tables in the current database. Here’s how to use it. The output above displays the list of the tables in the current databaseโฆ
Inserting values in a table in MySQL
After the creation of table one needs to insert the values. This is done using the ‘INSERT INTO’ query, it is used in many ways. The examples below show the uses on this query. Example 1 In the above query after the ‘insert into’ command we write the name of the table created and thenโฆ
Creating Tables in MySQL
After creating the database, the user must know the queries to create table, insert values in the table, selecting the values and displaying them, deleting a row, etc. CREATE TABLE To create table the ‘CREATE TABLE’ query is used as shown in the example below. In the above query ‘students’ is the name of theโฆ
Databases in MySQL
To start with databases in MySQL we use different queries for creating and using the databases. First of all to start with the basics we must know how to create a database in MySQL. It is done using the ‘CREATE DATABASE (name)’ query. Simply open the MySQL Command Line Client on your PC/laptop. Enter yourโฆ
Classification of SQL Statements
SQL, technically speaking is a data sublanguage that is it is a language used to interact with database. In other words all SQL statements are instructions to the database only. And that is where it differs from general purpose programming languages like C or CPP. SQL provides many different types of commands used for differentโฆ
Follow My Blog
Get new content delivered directly to your inbox.