- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
183 Views
For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20), -> Value int -> ); Query OK, 0 rows affected (2.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 50); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 90); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Chris', 60); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Bob', 100); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
232 Views
The correct way is as follows −DELIMITER // CREATE PROCEDURE yourStoredProcedureName() BEGIN IF yourCondition then yourStatement1 ; else yourStatement2 ; END IF ; END // DELIMITER ;Let us now see an example and create a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE delimiter_demo() -> BEGIN -> IF 1 THEN -> SELECT "If condition will always true"; -> else -> select "No" ; -> END IF ; -> END -> // Query OK, 0 rows affected (0.17 sec) mysql> DELIMITER ;Now you can call the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
108 Views
For this, you can use UNION in MySQL. Let us first create a table −mysql> create table DemoTable1 -> ( -> Value int -> ) -> ; Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(60); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1 values(78); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1 values(57); Query OK, 1 row affected (0.08 sec)Display all records from the table using select statement −mysql> select * from DemoTable1; This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
813 Views
For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable -> ( -> EmployeeName varchar(20), -> JoiningDate date, -> Salary int -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('David', '2019-11-02', 400); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable values('Robert', '2018-11-25', 100); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable values('Bob', '2019-12-14', 600); Query OK, 1 row affected (0.25 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
349 Views
The select and insert statements are the minimum required MySQL user privileges to allow optimize and repair.You can use below syntax to give insert and select privileges to the user −grant insert, select on yourDatabaseName.* to 'yourUserName'@'localhost';At first, here is the query to create a user −mysql> create user 'Emma'@'localhost' identified by 'Emma123'; Query OK, 0 rows affected (0.26 sec)Here is the query to give grants for the above user −mysql> grant insert, select on web.* to 'Emma'@'localhost'; Query OK, 0 rows affected (0.21 sec)Here is the query to display all grants of the above user −mysql> show grants for ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
80 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20), -> Amount int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 200); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Chris', 150); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Mike', 500); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('John', 350); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
878 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(101, 'Bob'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following output −+------+-------+ | Id ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20), -> Age int, -> CountryName varchar(10) -> ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris', 34, 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(101, 'Chris', 31, 'US'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(102, 'David', 25, 'UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(103, 'Carol', 28, 'AUS'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
109 Views
To implement a query like MySQL IN(), you need to use COUNT(), IF() along with LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> Subject varchar(80) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQLMongoDB'); Query OK, 1 row affected (0.86 sec) mysql> insert into DemoTable values('MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('JavaMySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('MongoDB'); Query OK, 1 row affected (0.20 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
361 Views
For this, you can use COALESCE(). For the maximum value, use GREATEST() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int, -> Value3 int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(NULL, 80, 76); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(NULL, NULL, 100); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(56, NULL, 45); Query OK, 1 row affected (0.20 sec) mysql> ... Read More