- 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)
592 Views
To create an empty view in MySQL, following is the syntax −create or replace view yourViewName as select yourValue AS yourColumnName, yourValue AS yourColumnName2, . . N from dual where false;Let us implement the above syntax in order to create an empty view in MySQL −mysql> create or replace view empty_view as select "John Smith" AS ClientName, "US" AS ClientCountryName, false AS isMarried from dual where false; Query OK, 0 rows affected (0.20 sec)Let us check the description of the view −mysql> desc empty_view;This will produce the following output -+-------------------+-------------+------+-----+---------+-------+ | Field ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
With the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP, a column has the current timestamp for its default value and is automatically updated to the current timestamp.Let us see an example and create a table −mysql> create table DemoTable737 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAdmissiondate datetime ); Query OK, 0 rows affected (0.68 sec)Following is the query to for CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP in MySQL −mysql> alter table DemoTable737 modify column StudentAdmissiondate timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; Query OK, 0 rows affected (2.20 sec) Records: 0 Duplicates: 0 Warnings: 0Let ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
989 Views
To update all the entries while ignoring a single value, you need to use IF().Let us first create a table −mysql> create table DemoTable736 ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100), isMarried boolean ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable736(CustomerName, isMarried) values('Chris', 0); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable736(CustomerName, isMarried) values('Robert', 0); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable736(CustomerName, isMarried) values('David', 0); Query OK, 1 row affected (0.24 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
39 Views
Let us first create a table −mysql> create table DemoTable(EmployeeCode varchar(100)); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('EMPLOYEE:100 John Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('EMPLOYEE:16537 Chris Brown'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('EMPLOYEE:100 David Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('EMPLOYEE:100 23432 David Miller'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql>; select *from DemoTable;This will produce the following output ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
To merge rows in MySQL, use GROUP_CONCAT().Let us first create a table−mysql> create table DemoTable734 ( Id int, Name varchar(100) ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command−mysql> insert into DemoTable734 values(101, 'John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable734 values(102, 'John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable734 values(103, 'Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable734 values(104, 'Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable734 values(104, 'Chris'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
112 Views
Let us first create a table -mysql> create table DemoTable732 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, PassengerId int, PassengerName varchar(100), PassengerAge int, PassengerTravelDatetime datetime ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command -mysql> insert into DemoTable732(PassengerId, PassengerName, PassengerAge, PassengerTravelDatetime) values(110, 'Chris', 25, '2019-07-23 12:45:56'); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable732(PassengerId, PassengerName, PassengerAge, PassengerTravelDatetime) values(120, 'Robert', 24, '2019-07-21 11:05:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable732(PassengerId, PassengerName, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
663 Views
To delete multiple entries from a MySQL table, use JOIN. Let us first create a table −mysql> create table DemoTabl(Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(FirstName) values('Bob'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(FirstName) values('Mike'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(FirstName) values('Adam'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable(FirstName) values('Bob'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Let us first create a table:mysql> create table DemoTable731 (Value varchar(100)); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command -mysql> insert into DemoTable731 values('4.50'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable731 values('7.83'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable731 values('8.91'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable731 values('560.34'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement -mysql> select *from DemoTable731;This will produce the following output -+--------+ | Value | +--------+ | 4.50 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
705 Views
To count days in date range, you need to find the difference between dates using DATEDIFF().Let us first create a table:mysql> create table DemoTable730 ( StartDate date, EndDate date ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command:mysql> insert into DemoTable730 values('2019-01-21', '2019-07-21'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable730 values('2018-10-11', '2018-12-31'); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable730 values('2016-01-01', '2016-12-31'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement:mysql> select *from DemoTable730;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
For this, use stored procedure. Let us first create a table −mysql> create table DemoTable(Id int, Name varchar(100)); Query OK, 0 rows affected (1.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 'John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(11, 'Chris'); Query OK, 1 row affected (0.41 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+------+-------+ | Id | Name | +------+-------+ | 10 | John | | 11 | Chris | +------+-------+ 2 rows ... Read More