
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4381 Articles for MySQL

134 Views
When we use AUTO_INCREMENT on a MySQL column, the sequence number always increases in ascending order starting from the default value 1 or from the value we specify.That is the reason, MySQL does not allow changing the AUTO_INCREMENT value to a value which is less than the current sequence number. It can be understood with the help of the following example −ExampleIn this example suppose we have a table named ‘emp1’ and while creating the table we specify the AUTO_INCREMENT VALUE to 100. Hence after inserting the values in table, the sequence would start from 100 onwards as can be ... Read More

133 Views
CHAR_LENGTH() or CHARACTER_LENGTH() string functions in MySQL are used to retrieve the length of a specified string. This function will simply count the number of characters and ignores whether the characters are of single-byte or multi-byte.Examplemysql> Select CHAR_LENGTH('New Delhi'); +--------------------------+ | CHAR_LENGTH('New Delhi') | +--------------------------+ | 9 | +--------------------------+ 1 row in set (0.00 sec) mysql> Select CHAR_LENGTH('NewDelhi'); +-------------------------+ | CHAR_LENGTH('NewDelhi') | +-------------------------+ | 8 | +-------------------------+ 1 row in set (0.00 sec) mysql> Select CHARACTER_LENGTH('NewDelhi'); ... Read More

476 Views
When CHAR_LENGTH() or CHARACTER_LENGTH() string function is used with WHERE clause, the output returns by it will depend upon the condition given in WHERE clause. For example, suppose we have a table named ‘Student’ and we want to get only those names having number of characters less than 6, then we can write following query −mysql> Select * from Student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 ... Read More

366 Views
While using the ASCII() function with WHERE clause, the output returns by it will depend upon the condition given in WHERE clause. For example, suppose we have a table named ‘Student’ and we want to get the number code, higher than 65, of the first characters of the names of the students. The query for this can be written as follows −mysql> Select * from student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | ... Read More

129 Views
In this case, the output of ASCII() function depends on the condition that whether we are providing NULL as a string or we are providing simply NULL to it. Following example will demonstrate the difference −mysql> SELECT ASCII(null); +-------------+ | ASCII(null) | +-------------+ | NULL | +-------------+ 1 row in set (0.00 sec) mysql> SELECT ASCII('null'); +---------------+ | ASCII('null') | +---------------+ | 110 | +---------------+ 1 row in set (0.00 sec) mysql> Select ASCII(NULL); +-------------+ | ASCII(NULL) | +-------------+ | NULL | +-------------+ 1 row in set ... Read More

165 Views
MySQL AUTO_INCREMENT value starts from 1 but we can change it with the help of following two ways −With the help of ALTER TABLE query We can use ALTER TABLE query to change the staring value of AUTO_INCREMENT as follows −ALTER TABLE table_name AUTO_INCREMENT = value;ExampleSuppose we have created a table having column ‘id’ as AUTO_INCREMENT. Now if we will insert the values in it then the sequence number would start from 1 as you can see this in following queries −mysql> Create Table EMP(id int NOT NULL PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(10)); Query OK, 0 rows affected (0.07 sec) ... Read More

783 Views
When the AUTO_INCREMENT column reaches the upper limit of data type then the subsequent effort to generate the sequence number fails. That is why it is advised to use a large enough integer data type for the AUTO_INCREMENT column to hold the maximum sequence value required by us. For example, if we will use TINYINT then AUTO_INCREMENT would be able to generate only 127 sequence numbers and in case of UNSIGNED TINYINT, this value can be extended up to 255.

115 Views
String function ASCII() in MySQL returns the ASCII number code of the specific character.SyntaxASCII(str)Here, str, the argument of ASCII() function, is the string whose ASCII value of the first character to be retrieved.It is pertinent to mention here that it will return the number code the left the most character i.e. first character of the string given as argument.Examplemysql> SELECT ASCII('A') as 'ASCII VALUE OF CAPITAL A'; +--------------------------+ | ASCII VALUE OF CAPITAL A | +--------------------------+ | 65 | +--------------------------+ 1 row in set (0.00 sec) mysql> SELECT ... Read More

265 Views
As we know that MySQL LAST_INSERT_ID() function returns the latest generated sequence number but in case of multiple row-insert it would return the sequence number generated by the foremost inserted row.Examplemysql> Insert into Student(Name) values('Ram'), ('Mohan'), ('Aryan'); Query OK, 3 rows affected (0.03 sec) Records: 3 Duplicates: 0 Warnings: 0The query above inserts three values in Student table with the help of Multiple-row insert query. The value of Column ‘Id’ can be checked with the help of the following query −mysql> Select * from Student; +----+-------+ | Id | Name | +----+-------+ | 1 | Raman | | 2 | ... Read More