- 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
108 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
188 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
76 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
190 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
54 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
138 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
159 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
697 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
647 Views
Set the JDBC MySQL URL in the DriverManager.getConnection to connect with IP Address. Following is the code to connect using IP Address −Exampleimport java.sql.Connection; import java.sql.DriverManager; public class JavaIP { public static void main(String[] args) { String hostURL = "jdbc:mysql://192.168.43.144:3306/web?useSSL=false"; Connection con = null; try { con = DriverManager.getConnection(hostURL, "root", "123456"); System.out.println("connection successful via ip address"); } catch (Exception e) { e.printStackTrace(); } } }OutputThis will produce the following output −connection successful via ip addressHere is the snapshot of the output −
966 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