
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

2K+ Views
The number 1 used in parenthesis is only for width display. The INT(1) and TINYINT(1) does not influence the storage.The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647To understand the width display, let us create a table −mysql> create table intAndTinyint −> ( −> FirstNumber int(1) zerofill, −> SecondNumber tinyint(1) zerofill −> ); Query OK, 0 rows affected (0.52 sec)Now you can insert records in the table. The query is as follows −mysql> insert into intAndTinyint values(1, 1); Query OK, 1 ... Read More

1K+ Views
You can get the first and last date of next month using date_add() function from MySQL.The syntax is as follows -select date_sub( last_day( date_add(now(), interval anyIntervalTime) ), interval day( last_day( date_add(now(), interval anyIntervalTime) ) )-1 DAY ) as anyVariableName, last_day ( date_add(now(), anyIntervalTime) ) as anyVariableName;Implement the above syntax to get the first and last date of next month using interval 1 month in date_add() function. The query is as follows.mysql> select -> date_sub( -> last_day( -> ... Read More

22K+ Views
To select multiple values, you can use where clause with OR and IN operator.The syntax is as follows −Case 1 − Using ORselect *from yourTablename where yourColumnName = value1 or yourColumnName = value2 or yourColumnName = value3, .........N;Case 2 − Using INselect *from yourTableName where yourColumnName IN(value1, value2, ....N);To understand the above syntax, let us create a table. The following is the query to create a table −mysql> create table selectMultipleValues −> ( −> BookId int, −> BookName varchar(200) −> ); Query OK, 0 rows affected (1.68 sec)Now you can insert some records in the table with the help of ... Read More

416 Views
You can insert multiple rows with the help of values() separated by comma(, ). The syntax is as follows −insert into yourTableName values(value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N), (value1, value2, ...N)................N;To insert multiple rows, let us create a table. The following is the query to create a table −mysql> create table MultipleRowsInsert −> ( −> UserId int, −> UserName varchar(200) −> ); Query OK, 0 rows affected (1.21 sec)Here is the query to insert multiple rows in the table −mysql> insert into MultipleRowsInsert values(100, 'Bob'), (101, 'Smith'), ... Read More

3K+ Views
DELIMITER in MySQL Triggers In MySQL, a DELIMITER command changes the delimiter from its default value of semicolon (;) to another string like //. This is really useful when creating stored procedures or triggers that contain multiple SQL statements, which may also include semicolons. Why do we Change the Delimiter in MySQL When you declare a trigger, you have to write a few SQL statements that may also involve control flow statements like IF conditions, which include semicolons. Unless you change the delimiter, MySQL will consider the first semicolon to be the end of the declaration of the ... Read More

90 Views
You can set value for a column of all records with the help of update command.The syntax is as follows if you want set NULL value for all the records in a column −update yourTableName set yourColumnName = NULL;Or if you want to use empty string, the following is the syntax −update yourTableName set yourColumnName = ’’;To understand the above concept, let us create a table. The query to create a table.mysql> create table StudentDemo −> ( −> Studentid int, −> StudentName varchar(100), −> Age int −> ); Query OK, 0 rows affected (0.64 sec)The ... Read More

2K+ Views
The value in the parentheses is used to display only the width and sets the zerofill. The width is 5 for int(5), whereas 10 for int(10). Let us see another example with a different width value set for int.Let us first create a table. Here, we have set the int to int(11) and int(13). The following is the query to create a table −mysql> create table intVsIntAnyThingDemo −> ( −> Number1 int(11) unsigned zerofill, −> Number int(13) unsigned zerofill −> ); Query OK, 0 rows affected (1.17 sec)Now you can insert record in the table with the help of insert ... Read More

403 Views
You can set the result of a query using select into command. The syntax is as follows.select yourColumnName1 into @anyVariableName from yourTableName where yourColumnName2='anyValue';Check the result is present in the variable or not using the select command. The syntax is as follows -select @anyVariableName;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table StudentInformation -> ( -> StudentId int, -> StudentName varchar(100), -> StudentAge int -> ); 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

289 Views
The difference between MySQL BigInt and int is that INT is a 32-bit long while BIGINT is 64-bit long.The following are some of the points −The BigInt takes 8 bytes of storage while int takes 4 bytes of storage.The int takes 4294967295 maximum values for int(10), whereas 18, 446, 744, 073, 709, 551, 615 for the bigint(20).The BigInt(20) and int(10), in this 20 and 10 can be used for width display with zerofill.Here is the demo of Bigint and int with zerofill. The following is the query to create a table.mysql> create table BigintandintDemo −> ( ... Read More

218 Views
To make MySQL’s NOW() and CURDATE() functions use UTC, you need to write my.cnf file. Write the below instruction in my.cnf −[mysqld_safe] timezone = UTCFirstly, reach the directory with the help of the following query −mysql> select @@datadir;The following is the output −+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Now reach the directory for which the link ... Read More