Categories
MySQL

MySQL Views

A database view is a virtual table which is defined as a SQL select query with JOIN statement. Same as database table it consists of rows and columns. When any data of a tables changes, the corresponding view reflects that changes as well. Advantages: A database view allows you to simplify complex queries. You do […]

Categories
MySQL

Data Types – MySQL

MySQL supports different data types while creating columns i.e. what type of value is using for the column or fixed/variable length etc. It has different types of data types i.e. Numeric: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, DECIMAL, FLOAT, DOUBLE, BIT String: CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT, ENUM, SET […]

Categories
MySQL

Use DISTINCT to eliminate duplicate rows

In a table there may be data available i.e. duplicate. Each time you querying and get all the duplicate data. Use DISTINCT to avoid it. Suppose in a coountry table there are two same country name the using DISTINCT you will get the only one name for each country. SELECT DISTINCT country_name FROM table_country;

Categories
MySQL

Understanding MySQL LEFT JOIN

MySQL LEFT JOIN allows you to get result set from two or more tables for certain matches. Suppose you have two tables i.e. A and B. So if you join A to B using left join then all rows from the A tables will be displayed with matches a row from the B table. Example […]

Categories
MySQL

Referential integrity

It is relational database concept in which multiple tables shares consistent relationship based on the data stored on tables. For example, a school X has 2 tables, a student table, and a student fee table. In the student table we have 2 columns – the student ID and the student name. In the student fee […]

Categories
MySQL

MySQL UPDATE Statement

Using MySQL UPDATE statement you can update existing data in a table. it can be a single column or multiple rows. Here is a simple example of MySQL UPDATE: UPDATE users SET user_address = ‘Kolkata, India’, user_state = ‘WB’ WHERE user_id = 247 You can also update fields depends on JOIN query on two or […]

Categories
MySQL

MySQL Storage Engines

When you create a database you have to choose the storage engine for storing data into the database. MySQL supports various types of storage engines i.e. MyISAM, InnoDB, MERGE, MEMORY (HEAP), ARCHIVE, CSV, FEDERATED. Each storage engines has different performance of the database and has advantages or disadvantages. Here is the list of MySQL Storage […]

Categories
MySQL

MySQL INNER JOIN

Using MySQL INNER JOIN you can match rows in one table with another table and get result set that contain columns from both tables. Suppose we have two tables user and order. So Using this join we will get the result row where userid from user table and userid from order table matches. Read Also: […]

Categories
MySQL

Primary Key, Unique Key, Key, Foreign Key

A primary key is a column or multiple columns that uniquely identify each row in a table.Basic key of primary key:– This must contain unique values– For multiple columns, the combination of values must be unique– Primary key is not null– Only one primary key will be present in a table As MySQL works faster […]

Categories
MySQL

MySQL ORDER BY & LIMIT

To sort a table columns in ascending or descending order you use ORDER BY clause. Using ASC and DESC you can get the result in ascending or descending order. You can also apply both order for different columns at the same time. ORDER BY EXAMPLE: SELECT name, address FROM users WHERE state = ‘AL’ ORDER […]