- 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 4219 Articles for MySQLi
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
You can use LIKE operator to find strings with a given prefix.The syntax is as followsselect *from yourTableName where yourColumnName LIKE 'yourPrefixValue%';To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table findStringWithGivenPrefixDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserMessage text -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hi Good Morning !!!'); Query OK, 1 row affected (0.17 sec) mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hey ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
17K+ Views
Use IFNULL or COALESCE() function in order to convert MySQL NULL to 0.The syntax is as followsSELECT IFNULL(yourColumnName, 0) AS anyAliasName FROM yourTableName; The second syntax is as follows: SELECT COALESCE(yourColumnName, 0) AS anyAliasName FROM yourTableName;Let us first create a table. The query to create a table is as followsmysql> create table convertNullToZeroDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Salary int -> ); Query OK, 0 rows affected (1.28 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into convertNullToZeroDemo(Name, Salary) values('John', ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
10K+ Views
You need to use ORDER BY clause to get the second last row of a table in MySQL.The syntax is as follows.select *from yourTableName order by yourColumnName DESC LIMIT 1, 1;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table secondLastDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(10) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command.The query is as follows.mysql> insert into secondLastDemo(StudentName) values('Larry'); Query OK, 1 row affected (0.15 ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
6K+ Views
You can use distinct keyword to select all values from a table only once if they are repeated.The syntax is as followsselect distinct yourColumnName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table displayOnlyDistinctValue -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(100), -> UserAge int -> ); 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 displayOnlyDistinctValue(UserName, UserAge) values('Larry', 23); Query OK, 1 row affected ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
17K+ Views
To select all entries from a particular month in MySQL, use the monthname() or month() function.The syntax is as follows.select *from yourTableName where monthname(yourColumnName)='yourMonthName';To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table selectAllEntriesDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into selectAllEntriesDemo(ShippingDate) values('2019-01-21'); Query OK, 1 row affected ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
496 Views
You need to use ALTER TABLE command along with MODIFYThe syntax is as followsALTER TABLE yourTableName MODIFY COLUMN yourColumnName varchar(100) NOT NULL;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table syntaxOfAlterCommandDemo -> ( -> UserId int, -> UserName varchar(30), -> UserAge int, -> UserCityName varchar(50) -> ); Query OK, 0 rows affected (0.51 sec)Let us check the description of the table.The query is as followsmysql> desc syntaxOfAlterCommandDemo;The following is the output+--------------+-------------+------+-----+---------+-------+ | Field | Type ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
188 Views
To replace values in a table, use the CASE statement. To understand the concept, let us create a table. The query to create a table is as followsmysql> create table replaceValueDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(10), -> isGreaterThan18 varchar(10) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into replaceValueDemo(Name, isGreaterThan18) values('John', 'YES'); Query OK, 1 row affected (0.24 sec) mysql> insert into replaceValueDemo(Name, isGreaterThan18) values('Carol', 'NO'); Query OK, 1 row affected (0.16 sec) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
To retrieve time as HH:MM format, use the DATE_FORMAT() function. To understand the function and retrieve time, let us create a table.The query to create a table is as followsmysql> create table retrieveTimeDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserArrivalTime datetime -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into retrieveTimeDemo(UserArrivalTime) values('2013-01-21 13:45:34'); Query OK, 1 row affected (0.16 sec) mysql> insert into retrieveTimeDemo(UserArrivalTime) values('2014-11-25 11:40:56'); Query OK, 1 row affected (0.11 sec) mysql> insert into retrieveTimeDemo(UserArrivalTime) ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
6K+ Views
To get the maximum value from three different columns, use the GREATEST() function.The syntax is as followsSELECT GREATEST(yourColumnName1, yourColumnName2, yourColumnName3) AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table MaxOfThreeColumnsDemo -> ( -> First int, -> Second int, -> Third int -> ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into MaxOfThreeColumnsDemo values(30, 90, 60); Query OK, 1 row affected (0.16 sec) mysql> insert into MaxOfThreeColumnsDemo values(100, ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
Restart the MySQL Server with the help of restart command.The syntax is as followsRestartLet us first check the MySQL version.The query is as followsSELECT version();Now, implement the above command in order to restart the MySQL Server.The query is as followsmysql> restart; Query OK, 0 rows affected (0.00 sec)Case 1Now, MySQL Server is being restarted. If you try to perform any query during the restart command, you will get an error.The query is as followsmysql> show databases; ERROR 2013 (HY000): Lost connection to MySQL server during queryCase 2If the MySQL restart process is complete, then a new connection id will be ... Read More