- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 6702 Articles for Database
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
343 Views
In order to work with hex, use the CONV() function to convert between bases. The syntax is as follows −SET anyVariableName = CONV(yourHexValue, 16, 10);To understand the above syntax, let us create a stored procedure. The query to create a stored procedure is as follows −mysql> DELIMITER // mysql> CREATE PROCEDURE SP_HEX_TO_DEC( HEXVALUE VARCHAR(10) ) -> BEGIN -> DECLARE Decimalvalue INTEGER; -> SET Decimalvalue = CONV(HEXVALUE, 16, 10); -> select Decimalvalue; -> END; -> // Query OK, 0 rows affected (0.19 sec) mysql> DELIMITER ;The above stored procedure converts the hexadecimal to decimal. As ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
343 Views
You can use CREATE TABLE command to create a table from an existing table. The syntax is as follows:CREATE TABLE yourNewTableName LIKE yourOldTableNameTo understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ShowCreateTableCommand -> ( -> Id int NOT NULL AUTO_INCREMENT, -> FirstName varchar(20), -> LastName varchar(20), -> Age int, -> TotalMarks int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.22 sec)Here is the query to describe a table using DESC command. The query is as follows:mysql> desc ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
111 Views
You need to use ALTER command to change collation to utf8_bin. The syntax is as follows:ALTER TABLE yourTableName COLLATE utf8_general_ci;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table CollateDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> Age int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.98 sec)Check the DDL of the table. The syntax is as follows:SHOW CREATE TABLE yourTableName;Let us now check the DDL of our table:mysql> show create table CollateDemo;The following is ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
You can use binary to search for exact string in MySQL. The syntax is as follows:SELECT * FROM yourTableName WHERE BINARY yourColumnName = yourStringValue;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ExactSearch -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserId varchar(10), -> UserName varchar(20), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into ExactSearch(UserId, UserName) values('USER12', 'John'); Query OK, 1 row ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
18K+ Views
Use STR_TO_DATE() method from MySQL to convert. The syntax is as follows wherein we are using format specifiers. The format specifiers begin with %.SELECT STR_TO_DATE(yourDateColumnName, '%d.%m.%Y') as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table ConvertIntoDateFormat -> ( -> Id int NOT NULL AUTO_INCREMENT, -> LoginDate varchar(30), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into ConvertIntoDateFormat(LoginDate) values('11.01.2019'); Query OK, 1 ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
45 Views
You can use CASE statement to get the results that match some expressions−SELECT *FROM yourTableName WHERE CASE WHEN yourColumnName1 = yourValue1 THEN 1 ELSE 0 END + CASE WHEN yourColumnName2 = yourValue2 THEN 1 ELSE 0 END + CASE WHEN yourColumnName3 = yourValue3 THEN 1 ELSE 0 END + . . CASE WHEN yourColumnNameN = yourValueN THEN 1 ELSE 0 END > = 3;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UserInformation -> ( -> Id int NOT NULL AUTO_INCREMENT, ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
You can select all records that are 10 minutes within current timestamp using the following syntax−SELECT *FROM yourTableName WHERE yourColumnName > = DATE_SUB(NOW(), INTERVAL 10 MINUTE);To understand the above syntax, let us create a table. The query to create a table is as follows−mysql> create table users -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserName varchar(20), -> UserLastseen datetime, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.91 sec)Insert some records in the table using insert command. The query is as follows−mysql> insert into users(UserName, UserLastseen) values('Larry', '2019-01-15 02−45−00'); Query ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
You can grab the current date with CURDATE() and the day before with MySQL using DATE_SUB() with INTERVAL 1 DAY. The syntax is as follows:SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY);The syntax is as follows to get curdate and the day before with date_sub().SELECT *FROM yourTableName WHERE yourColumnName = CURDATE() OR yourColumnName = DATE_SUB(CURDATE(), INTERVAL 1 DAY);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ProductDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> ProductName varchar(20), -> ProductOfferDate datetime, -> PRIMARY KEY(Id) -> ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
1K+ Views
You can use CONCAT() method to concatenate values while IFNULL() method is used to handle NULL values. The syntax is as follows:SELECT CONCAT('anyStringValue:', IFNULL(yourColumnName, 'anyStringValue’)) AS anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ConcatValues -> ( -> Id int NOT NULL AUTO_INCREMENT, -> FirstName varchar(20), -> MiddleName varchar(20), -> LastName varchar(20), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
914 Views
The limit of auto_increment integer depends on column data type. Displayed as follows:The data type TINYINT range is 127 The data type UNSIGNED TINYINT range is 255 The data type SMALLINT range is 32767 The data type UNSIGNED SMALLINT range is 65535 The data type MEDIUMINT range is 8388607 The data type UNSIGNED MEDIUMINT range is 16777215 The data type INT range is 2147483647 The data type UNSIGNED INT range is 4294967295 The data type BIGINT range is 9223372036854775807 The data type UNSIGNED BIGINT range is 18446744073709551615Let us take an example of TINYINT. If you will give beyond 127, then ... Read More