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... Continue Reading →
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 select SUM(columnname) from tablename where condition; EXAMPLE select SUM(Score) from students; AVG AVG() returns the average of the numeric values of a specific column. SYNTAX select AVG(columnname)... Continue Reading →
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() : Select MAX(columnname) From tablename Where condition; MIN(): Select MIN(columnname)... Continue Reading →
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... Continue Reading →
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... Continue Reading →
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... Continue Reading →
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... Continue Reading →
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: 1. SELECT column name...[column names] from Table name WHERE(condition 1 AND condition... Continue Reading →
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... Continue Reading →
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... Continue Reading →
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 databases; Show Tables: It is display the of all the tables in the current database. Here's how to use it. show tables; The output above displays the list of the tables... Continue Reading →
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 insert into students values(1,'Emily',12,'A','Physics'); insert into students values(2,'Lilly',12,'C','Biology'); In the above query after the 'insert into' command we write... Continue Reading →
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. create table students(Roll int, Name varchar(10), Class int, Section varchar(5),... Continue Reading →
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... Continue Reading →