- 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)
134 Views
For this, use STR_TO_DATE() along with DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1985 ( DueDate varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1985 values('Jan 2017'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1985 values('May 2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1985 values('Aug 2015'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1985;This will produce the following output −+----------+ | DueDate | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
566 Views
Let’s say you need to change the date and add years. For this, use UPDATE command along with DATE_ADD(). Let us first create a table −mysql> create table DemoTable1984 ( ShippingDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1984 values('2014-01-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1984 values('2015-12-23'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1984 values('2017-10-31'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1984 values('2018-06-01'); 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)
232 Views
To insert a row like this use the following syntax, wherein we are using CURRENT_TIMESTAMP −insert into yourTableName values(CURRENT_TIMESTAMP - INTERVAL ABS(RAND() * 100) DAY);To understand the above syntax, let us create a table −mysql> create table DemoTable1983 ( DueDate timestamp ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1983 values(CURRENT_TIMESTAMP - INTERVAL ABS(RAND() * 100) DAY); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1983 values(CURRENT_TIMESTAMP - INTERVAL ABS(RAND() * 100) DAY); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1983 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
261 Views
Let us first create a table −mysql> create table DemoTable1982 ( StudentId int , StudentName varchar(20), StudentAge int ); Query OK, 0 rows affected (0.00 sec)Let us check the table engine type -mysql> show create table DemoTable1982;This will produce the following output −+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
410 Views
For this, use UNION ALL along with SUM(). Let us create 5 tables −mysql> create table DemoTable1977 ( UP int ); Query OK, 0 rows affected (0.00 sec) mysql> insert into DemoTable1977 values(10); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1977 values(20); Query OK, 1 row affected (0.00 sec) mysql> select * from DemoTable1977; +------+ | UP | +------+ | 10 | | 20 | +------+ 2 rows in set (0.00 sec) mysql> create table DemoTable1978 ( UP int ); Query OK, 0 rows affected (0.00 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
For this, use IF() with IS NULL property. Let us first create a table −mysql> create table DemoTable1976 ( FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1976 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values('John', NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values(NULL, 'Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values('Chris', 'Brown'); Query OK, 1 row affected (0.00 sec)Display all records from the table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
168 Views
Let us first create a table −mysql> create table DemoTable1975 ( StudentName varchar(20), StudentMarks int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1975 values('John', 45); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('Chris', 67); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('David', 59); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('Bob', NULL); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1975;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
437 Views
For this, use prepared statement. Let us first create a table −mysql> create table DemoTable1973 ( StudentId int, StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1973 values(101, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(102, 'John Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(103, 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(104, 'John Smith'); Query OK, 1 row affected (0.00 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
362 Views
Let us first create a table −mysql> create table DemoTable1972 ( Section char(1), StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1972 values('D', 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('B', 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('A', 'Mike'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('C', 'Carol'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1972;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
Let us first create a table −mysql> create table DemoTable1971 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20), StudentPassword int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1971(StudentName, StudentPassword) values('John', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('Chris', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('David', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('Mike', '123456'); Query OK, 1 row affected (0.00 sec)Display all ... Read More