- 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)
161 Views
Let us first create a table −mysql> create table DemoTable778 ( ClientId varchar(100), ClientName varchar(100) ); Query OK, 0 rows affected (1.05 sec)Insert some records in the table using insert command −mysql> insert into DemoTable778 values('J-101', 'John'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable778 values('A-102', 'Adam'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable778 values('C-103', 'Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable778 values('D-104', 'David'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable778 values('R-105', 'Robert'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
57 Views
Let us first create a table −mysql> create table DemoTable777 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAge int ); Query OK, 0 rows affected (1.34 sec)Insert some records in the table using insert command −mysql> insert into DemoTable777(StudentName, StudentAge) values('Chris', 23); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable777(StudentName, StudentAge) values('Robert', 21); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable777(StudentName, StudentAge) values('Mike', 19); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable777(StudentName, StudentAge) values('Bob', 22); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
Let’s say you have set column values as unique key and try to insert duplicate values in the table. This will lead to ERROR 1062 (23000): Duplicate entry.Let us first create a table -mysql> create table DemoTable776 ( FirstValue int, SecondValue int, unique key(FirstValue, SecondValue) ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command. While inserting duplicate value, the same error arises as shown below -mysql> insert into DemoTable776 values(10, 20); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable776 values(10, 40); Query OK, 1 row affected (0.15 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
263 Views
Let us first create a table −mysql> create table DemoTable775 ( FirstName varchar(100) ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable775 values('Adam') ; Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable775 values('Carol'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable775 values('John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable775 values('Sam'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable775 values('Adan'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
8K+ Views
The current date format is ‘YYYY-mm-dd’. To change current date format, you can use date_format().Let us first display the current date −mysql> select curdate();This will produce the following output −+------------+ | curdate() | +------------+ | 2019-08-08 | +------------+ 1 row in set (0.00 sec)Following is the query to change curdate() (current date) format −mysql> select date_format(curdate(), '%m/%d/%Y');This will produce the following output −+------------------------------------+ | date_format(curdate(), '%m/%d/%Y') | +------------------------------------+ | 08/08/2019 | +------------------------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
908 Views
For this, use aggregate function SUM(). Within this method, multiply the row values. Let us first create a table −mysql> create table DemoTable( ProductQuantity int, ProductPrice int ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 9); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(6, 20); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(7, 100); Query OK, 1 row affected (0.08 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
834 Views
For this, use GROUP BY clause along with aggregate function SUM(). Let us first create a table −mysql> create table DemoTable( Name varchar(100), Score int ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 50); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Bob', 80); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Adam', 70); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Adam', 10); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Carol', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
120 Views
Let us first create a table −mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName) values('Adam Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(CustomerName) values('Chris Brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(CustomerName) values('David Miller'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(CustomerName) values('Carol Taylot'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(CustomerName) values('Carol Taylor'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
6K+ Views
For this, you can use CASE statement. Let us first create a table −mysql> create table DemoTable( Id int, Value int ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 100); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(10, -110); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(10, 200); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(10, -678); Query OK, 1 row affected (0.17 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)
390 Views
Let us first create a table −mysql> create table DemoTable( EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeName varchar(100), JoiningDate date ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(EmployeeName, JoiningDate) values('Chris', '2019-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(EmployeeName, JoiningDate) values('Robert', '2016-12-01'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(EmployeeName, JoiningDate) values('Mike', '2015-03-12'); 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 −+------------+--------------+-------------+ ... Read More