- 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
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
168 Views
Problem: Write a query on TRANSACTIONS DB2 table to list down the number of orders (ORDER_ID) assigned to a particular transaction (TRANSACTION_ID).SolutionWe can use the below query to find out the number of orders assigned to a particular transaction id on TRANSACTIONS DB2 table.ExampleSELECT TRANSACTION_ID, COUNT(ORDER_ID) FROM TRANSACTIONS GROUP BY TRANSACTION_IDWe will use GROUP BY function on the ORDER_ID to fetch the result order wise. The COUNT function will count the number of orders. For example, we have below DB2 ORDERS table.TRANSACTION_IDORDER_IDIRN22345A23118IRN22345A45901IRN22345A67990IRN56902A23119IRN99781A67921IRN56902A23167 The result of our DB2 query will return the below result.TRANSACTION_IDCOUNT(ORDER_ID)IRN223453IRN569022IRN997811Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, use application.properties −spring.datasource.username=yourMySQLUserName spring.datasource.password=yourMySQLPassword spring.datasource.url=jdbc:mysql://localhost:3306/yoruDatabaseName spring.datasource.driver-class-name=com.mysql.cj.jdbc.DriverTo understand the above syntax, let us create a table −mysql> create table demo71 −> ( −> id int, −> name varchar(20) −> ); Query OK, 0 rows affected (3.81 sec)Insert some records into the table with the help of insert command −mysql> insert into demo71 values(100, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into demo71 values(101, 'David'); Query OK, 1 row affected (0.49 sec) mysql> insert into demo71 values(102, 'Bob'); Query OK, 1 row affected (0.15 sec)Display records from the table using select statement −mysql> select *from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
The difference between AND, OR is that AND evaluates both conditions must be true for the overall condition to be true. The OR evaluates one condition must be true for the overall condition to be true.Let us create a table −mysql> create table demo70 −> ( −> id int not null auto_increment primary key, −> name varchar(20), −> age int −> ); Query OK, 0 rows affected (0.67 sec)Insert some records into the table with the help of insert command −mysql> insert into demo70(name, age) values('John', 23); Query OK, 1 row affected (0.18 sec) mysql> insert into demo70(name, age) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
175 Views
For this, use UPDATE command along with SUBSTRING_INDEX(). Let us first create a table −mysql> create table demo69 −> ( −> name varchar(40) −> ); Query OK, 0 rows affected (5.04 sec)Insert some records into the table with the help of insert command −mysql> insert into demo69 values('John/Smith'); Query OK, 1 row affected (0.83 sec) mysql> insert into demo69 values('David/Miller'); Query OK, 1 row affected (0.23 sec) mysql> insert into demo69 values('Chris/Brown'); Query OK, 1 row affected (0.40 sec) mysql> insert into demo69 values('Carol/Taylor'); Query OK, 1 row affected (0.36 sec)Display records from the table using select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
66 Views
For this, use CASE WHEN concept. Let us first create a table −mysql> create table demo68 −> ( −> id int not null auto_increment primary key, −> company_name varchar(50), −> employee_name varchar(50), −> country_name varchar(50) −> ); Query OK, 0 rows affected (1.86 sec)Insert some records into the table with the help of insert command −mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'John', 'US'); Query OK, 1 row affected (0.29 sec) mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'Bob', 'UK'); Query OK, 1 row affected (0.10 sec) mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'David', 'AUS'); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
90 Views
Following is the syntax to display only the first 3 rows with LIMIT set in a range −select *from yourTableName limit yourStartIndex, yourEndIndex;Let us first create a table −mysql> create table demo67 −> ( −> id int, −> user_name varchar(40), −> user_country_name varchar(20) −> ); Query OK, 0 rows affected (0.72 sec)Insert some records into the table with the help of insert command −mysql> insert into demo67 values(10, 'John', 'US'); Query OK, 1 row affected (0.19 sec) mysql> insert into demo67 values(1001, 'David', 'AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into demo67 values(101, 'Mike', 'UK'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
116 Views
Following is the syntax −select *from yourTableName where REGEXP_INSTR(yourColumnName, yourSearchValue);To understand the above syntax, let us first create a table −mysql> create table demo64 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> ); Query OK, 0 rows affected (3.06 sec)Insert some records into the table with the help of insert command −mysql> insert into demo64(name) values('John Smith'); Query OK, 1 row affected (0.21 sec) mysql> insert into demo64(name) values('John Doe'); Query OK, 1 row affected (0.15 sec) mysql> insert into demo64(name) values('Chris Brown'); Query OK, 1 row affected (0.08 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
6K+ Views
To encrypt and decrypt in MySQL, use the AES_ENCRYPT() and AES_DECRYPT() in MySQL −insert into yourTableName values(AES_ENCRYPT(yourValue, yourSecretKey)); select cast(AES_DECRYPT(yourColumnName, yourSecretKey) as char) from yourTableName;To understand the above syntax, let us first create a table −mysql> create table demo63 −> ( −> value blob −> ); Query OK, 0 rows affected (2.60 sec)Insert some records into the table with the help of insert command. We are encrypting while inserting −mysql> insert into demo63 values(AES_ENCRYPT('John', 'PASS')); Query OK, 1 row affected (0.18 sec) mysql> insert into demo63 values(AES_ENCRYPT('David', 'PASS')); Query OK, 1 row affected (0.41 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
147 Views
For this, use INSERT INTO SELECT statement in MySQL. Let us create a table −mysql> create table demo61 −> ( −> id int, −> name varchar(20) −> ) −> ; Query OK, 0 rows affected (1.84 sec)Insert some records into the table with the help of insert command −mysql> insert into demo61 values(1, 'John'); Query OK, 1 row affected (0.63 sec) mysql> insert into demo61 values(2, 'David'); Query OK, 1 row affected (0.13 sec) mysql> insert into demo61 values(1, 'Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into demo61 values(2, 'Carol'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
401 Views
Following is the syntax −select yourColumnName1, yourColumnName2, yourColumnName3, . . . N from yourTableName where yourValue in(yourColumnName1, yourColumnName2) or yourColumnName1 is NULL;Let us create a table −mysql> create table demo60 −> ( −> id int not null auto_increment primary key, −> first_name varchar(20), −> last_name varchar(20) −> ) −> ; Query OK, 0 rows affected (2.11 sec)Insert some records into the table with the help of insert command −mysql> insert into demo60(first_name, last_name) values('John', 'Smith'); Query OK, 1 row affected (0.09 sec) mysql> insert into demo60(first_name, last_name) values('John', 'Doe'); Query OK, 1 row affected (0.51 sec) mysql> insert ... Read More