
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

156 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('20'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('10.5'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('11'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('10'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('20.5'); Query OK, 1 row affected (0.13 sec)Display all records from the table ... Read More

237 Views
Use the STR_TO_DATE() method to insert date records as in the below syntax −select str_to_date(yourColumnName, '%b %Y') from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> JoiningYear varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Jan 2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('May 2107'); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('Aug 2019'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Oct 2020'); Query OK, ... Read More

129 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Version varchar(20) -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1.0.0'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2.s6.9'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('1.5.0'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------+ | Version | +---------+ | 1.0.0 | | 2.s6.9 | ... Read More

263 Views
Use FORMAT() in MySQL to display currency records and display them in the correct form. Let us first create a table −mysql> create table DemoTable -> ( -> Amount DECIMAL(15, 4) -> ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(90948484); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1000000000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(1535353536); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(773646463); Query OK, 1 row affected (0.20 sec)Display all ... Read More

84 Views
For this, use LEFT in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Java database connectivity to MySQL database'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Python with django framework'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('C with data structure and algorithm'); Query OK, 1 row affected (0.33 sec)Display all records from the table using select statement −mysql> select ... Read More

244 Views
For this, use CASE statement along with FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1629 -> ( -> Month varchar(100) -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command.mysql> insert into DemoTable1629 values('2, 4, 6'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1629 values('1, 3, 5, 12'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1629 values('7, 8, 9, 10'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement − mysql> select ... Read More

254 Views
For this, you can use GROUP BY MONTH(). Let us first create a table −mysql> create table DemoTable1628 -> ( -> PurchaseDate date, -> Amount int -> ); Query OK, 0 rows affected (1.55 sec)Insert some records in the table using insert command.mysql> insert into DemoTable1628 values('2019-01-10', 1500); Query OK, 1 row affected (0.68 sec) mysql> insert into DemoTable1628 values('2019-10-10', 2000); Query OK, 1 row affected (0.61 sec) mysql> insert into DemoTable1628 values('2019-10-24', 100); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1628 values('2019-11-10', 500); Query OK, 1 row affected ... Read More

797 Views
To set default, you can use the DEFAULT keyword in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeJoiningDate datetime default '0000-00-00 00:00:00' -> )ENGINE=MyISAM, AUTO_INCREMENT=100; Query OK, 0 rows affected (0.21 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(EmployeeName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(EmployeeName) values('David'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(EmployeeName) values('Mike'); Query OK, 1 row affected (0.03 sec) mysql> ... Read More

932 Views
In this article, we will learn how to connect a Java application to a MySQL database hosted on a specific IP address. By specifying the IP address in the connection URL, we can directly connect to the database even if it’s on a different machine. We’ll use the DriverManager.getConnection() method to initiate the connection. Steps to connect a MySQL database via IP Address Following are the steps to connect a MySQL database via IP Address − Import Connection and DriverManager classes from the java.sql package to enable database connectivity. Create a String ... Read More

1K+ Views
For this, you can use IF() along with aggregate function SUM(). Let us first create a table −mysql> create table DemoTable1617 -> ( -> Attendance varchar(20), -> CurrentYear int -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1617 values('Present', 2019); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1617 values('Absent', 2019); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1617 values('Absent', 2017); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1617 values('Present', 2019); Query ... Read More