- 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)
812 Views
To store BloodType, use varchar(3) or ENUM. Let us first create a table −mysql> create table DemoTable1855 ( BloodType varchar(3) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1855 values('A+'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('A-'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('B+'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('B-'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1855 values('AB+'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
145 Views
To find distinct number of specific items, use COUNT() along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable1854 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1854 values('John-Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1854 values('Chris-Brown'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1854 values('Adam-Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1854 values('John-Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
296 Views
For this, use ORDER BY RAND() with subquery. Let us first create a table −mysql> create table DemoTable1853 ( UserId int NOT NULL AUTO_INCREMENT, PRIMARY KEY(UserId) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1853 values(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
86 Views
If you try to compare string to int, MySQL won’t raise an error because it converts string to int. Let us first create a table −mysql> create table DemoTable1852 ( Value1 varchar(20), Value2 int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1852 values('1John', 1); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1852 values('John', 1); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1852 values('1', 1); Query OK, 1 row affected (0.00 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, use DELETE command. Let us first create a table −mysql> create table DemoTable1851 ( DueDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1851 values('2019-12-03 21:30:35'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1851 values('2019-12-03 21:45:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1851 values('2019-12-03 21:34:00'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1851; This will produce the following output −+---------------------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
514 Views
Let us first create a table −mysql> create table DemoTable1850 ( OrderStatus varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1850 values('Yes'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1850 values('No'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1850 values('Yes'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1850 values('Yes'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1850; This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
991 Views
For this, you can use IFNULL() or COALESCE(). Let us first create a table −mysql> create table DemoTable1849 ( ClientFirstName varchar(20), ClientLastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1849 values('John', NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values(NULL, 'Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values(NULL, NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values('Chris', 'Brown'); Query OK, 1 row affected (0.00 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
748 Views
To add time to datetime, use ADDTIME() function in MySQL. Let us first create a table −mysql> create table DemoTable1848 ( ShippingDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1848 values('2019-10-11 12:30:45'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-01-12 10:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-12-03 17:30:00'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1848; This will produce ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
368 Views
Let us first create a table −mysql> create table DemoTable1847 ( GameStatus ENUM('PENDING', 'COMPLETED', 'CANCELLED') ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1847 values('PENDING'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('COMPLETED'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('CANCELLED'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1847; This will produce the following output −+------------+ | GameStatus | +------------+ | PENDING ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
663 Views
For this, use MONTH() and YEAR(). Let us first create a table −mysql> create table DemoTable1846 ( PurchaseDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1846 values('2019-01-10'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2019-12-24'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2018-09-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2017-10-26'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * ... Read More