
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 4218 Articles for MySQLi

950 Views
For this, you can use the concept of INTERVAL and DATE_SUB(). Let us first create a table −mysql> create table DemoTable1845 ( ArrivalDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1845 values('2019-12-02'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-11-18'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-12-18'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-12-25'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-11-15'); Query ... Read More

4K+ Views
For this, you can use CONCAT() and round(). Let us first create a table −mysql> create table DemoTable1844 ( Number int, TotalNumber int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1844 values(50, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(80, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(98, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(45, 500); Query OK, 1 row affected (0.00 sec)Display all ... Read More

558 Views
For this, use MySQL YEAR() function. Let us first create a table −mysql> create table DemoTable1843 ( StartDate date, EndDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1843 values('2019-01-21', '2019-10-12'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1843 values('2018-10-12', '2018-12-31'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1843 values('2016-04-01', '2017-05-02'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1843;This will produce the ... Read More

485 Views
To multiply with NULL row, you can use COALESCE(). Let us first create a table −mysql> create table DemoTable1842 ( NumberOfItems int, Amount int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1842 values(10, 40); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1842 values(20, 5); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1842 values(NULL, 10); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1842;This ... Read More

149 Views
For this, you can use WHERE clause along with subquery. Let us first create a table −mysql> create table DemoTable1840 ( UserName varchar(20), UserType ENUM('GUEST', 'ADMIN') ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1840 values('Chris', 'Admin'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1840 values('David', 'Guest'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1840 values('Chris', 'Guest'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * ... Read More

227 Views
The syntax for the fastest way is given below. Here, we have used INSERT INTO just once and formed an optimized way −insert into yourTableName values(NULL, yourValue1', yourValue2), (NULL, yourValue1', yourValue2), ....N;Let us first create a table −mysql> create table DemoTable1839 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20), ClientAge int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1839 values(NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', ... Read More

520 Views
To connect Java to MySQL, the Java code is as follows −import java.sql.Connection; import java.sql.DriverManager; public class LostConnectionURLDemo { public static void main(String[] args){ String JDBCURL="jdbc:mysql://localhost:3306/web?autoReconnect=true"; Connection con=null; try{ con = DriverManager.getConnection(JDBCURL,"root","123456"); System.out.println("connection is established"); } catch(Exception e){ e.printStackTrace(); } } }This will produce the following output −

223 Views
To sort search results based on substring position, use ORDER BY LOCATE(). Let us first create a table −mysql> create table DemoTable1838 ( Subject varchar(100) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1838 values('MongoDB MySQL'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1838 values('MySQL Java'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1838 values('JavaWithMySQL'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1838; This will ... Read More

484 Views
Let us first create a table −mysql> create table DemoTable1837 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1837(StudentName) values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Bob'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Mike'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement ... Read More

796 Views
This error occurs when we use TYPE for ENGINE NAME. The error is as follows −mysql> create table DemoTable1836 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20) )Type=MyISAM AUTO_INCREMENT=1; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Type=MyISAM AUTO_INCREMENT=1' at line 5Now, in MySQL 8, you can use ENGINE instead of Type. Let us first create a table −mysql> create table DemoTable1836 ( ClientId int NOT ... Read More