PHP Tutorials
- What is MySqli
- mysql query
- mysql query example
- InnoDB
- mysql column Type
- CRUD Example
- Connection Using Function
- mysql keys
- SELECT
- WHERE
- UPDATE
- Count no of Rows
- ALIAS
- AND, AND & OR
- BETWEEN
- COMPARISON OPERATOR
- DELETE
- DELETE LIMIT
- DISTINCT
- EXISTS
- FROM
- GROUP BY
- HAVING
- IN
- INTERSECT
- IS NULL & IS NOT NULL
- LIKE
- NOT
- ORDER BY
- SELECT LIMIT
- SUBQUERY
- TRUNCATE
- UNION && UNION ALL
- Concat & Group_Concat
- mysql Function
- Mysql Insert Id
- MySql Aggregate Function
- Mysql Join
- JOIN in MySql
- Trigger
- Procedure
- Transaction
- views
- Index
- SQL Injection
- Normalization
- Query Bind
- Interview Questions
Important Link
MySql Column Type
Similarities between DATETIME & TIMESTAMP
Difference between DATETIME & TIMESTAMP
File Name :
DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MI:SS
TIMESTAMP - format: YYYY-MM-DD HH:MI:SS
YEAR - format YYYY or YY
varchar AND text
File Name :
Text :-
store a paragraph or more of text
don't need to index the column
If you have reached the row size limit for your table
you cannot put an index (except for a fulltext index) on a TEXT column.
both data types have a maximum length of 65,535 characters.
varchar :-
store a few words or a sentence
index the (entire) column
use the column with foreign-key constraints
if you want to have an index on the column, you have to use VARCHAR.
ENUM
ENUM data type is a string object. It allows us to limit the value chosen from a list of permitted values in the column specification at the time of table creation.
When you create ENUM, you create a list of items from which the value must be selected (or it can be NULL).
each column may have one of the specified possible values. It uses numeric indexes (1, 2, 3…) to represent string values.
File Name :
CREATE TABLE trendelook(
id INT PRIMARY KEY AUTO_INCREMENT,
product_name VARCHAR(35),
size ENUM('small', 'medium', 'large','x-large')
);
INSERT INTO trendelook (id, name, size)
VALUES (1,'t-shirt', 'medium'),
(2, 'casual-shirt', 3),
(3, 'formal-shirt', 4),
(4, 'party-shirt', 'small');
File Name :
SELECT * FROM trendelook;
id name size
1 t-shirt medium
2 casual-shirt large
3 formal-shirt x-large
4 party-shirt small
ENUM AND SET
The SET and ENUM data types work in a similar way because MySQL uses it with a predefined list of values.
ENUM data type can hold only a single member of the predefined list of values, whereas SET data type allows us to store zero or any number of values together.
File Name :
SET datatype
A SET is a string object that can store zero or more values. set must be chosen from a predefined list of values specified during table creation.
The SET and ENUM data types work in a similar way because MySQL uses it with a predefined list of values.
SET values are separated by commas (,).
File Name :
CREATE TABLE itechxpert(
Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name SET('mahtab','sana','sara','simran')
);
File Name :
File Name :
File Name :
File Name :
File Name :
File Name :