- 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)
556 Views
Let us first create a table −mysql> create table DemoTable ( FirstDate datetime, SecondDate datetime ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-01-21', '2018-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-10-04', '2019-08-14'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2019-05-01', '2019-09-11'); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values(NULL, NULL); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-03-01', NULL); Query OK, 1 row affected (0.13 sec)Display all records ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
946 Views
First, you need to prepare a query and then you need to execute the PREPARED statement to dynamically choose a column in MySQL.Let us first create a table −mysql> create table DemoTable ( EmployeeName varchar(100) ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Doe'); 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 −+--------------+ | EmployeeName | +--------------+ | John Doe | +--------------+ 1 row in set ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
251 Views
Let us first create a table −mysql> create table DemoTable ( AdmissionDate varchar(100) ); Query OK, 0 rows affected (1.06 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2018-01-21'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-08-13'); Query OK, 1 row affected (0.56 sec) mysql> insert into DemoTable values('2019-07-08'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2016-02-12'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------+ | AdmissionDate | +---------------+ ... 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 ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.92 sec) mysql> alter table DemoTable add index(FirstName, LastName); Query OK, 0 rows affected (1.00 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (0.73 sec) mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (1.17 sec) mysql> insert into DemoTable values('John', 'Doe'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
536 Views
For this, use UNION. Let us first create a table −mysql> create table DemoTable ( Name1 varchar(100), Name2 varchar(100) ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert commandmysql> insert into DemoTable values('Adam', 'Bob'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Adam', 'Bob'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 'Chris'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-------+-------+ | Name1 | Name2 | +-------+-------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
347 Views
For this, use a CASE statement. Let us first create a table −mysql> create table DemoTable ( Value char(1) ); Query OK, 0 rows affected (1.21 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('a'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('b'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('a'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('a'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('b'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
224 Views
Yes, we can use INTERVAL while inserting data records. Let us first create a table −mysql> create table DemoTable ( ArrivalTime datetime ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command. Here, we are using INTERVAL keyword for incrementing the date records while inserting −mysql> insert into DemoTable values(date_add(now(), interval 4 hour)); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(date_add('2016-01-31 10:40:50', interval 2 hour)); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(date_add('2015-05-01 12:00:00', interval 1 hour)); Query OK, 1 row affected (0.25 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
104 Views
Yes, you can give the year as a column name in MySQL table since it isn’t a reserved word. Let us first create a table −mysql> create table DemoTable ( Year int ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1995); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(2019); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2016); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2018); Query OK, 1 row affected (0.13 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
279 Views
To concatenate rows on the basis of boolean value in another column, use GROUP_CONCAT(). Let us first create a table. Here, we have set one of the columns “isValidUser” as BOOLEAN −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserMessage varchar(100), isValidUser boolean ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserMessage, isValidUser) values('Hi', true); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable(UserMessage, isValidUser) values('Hello', false); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(UserMessage, isValidUser) values('Good', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
88 Views
To ORDER BY letters, use ORDER BY SUBSTRING(). Let us first create a table −mysql> create table DemoTable ( Id varchar(100) ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('456 John Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('897 Adam Smith'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('1009 Bob Smith'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------------+ | Id ... Read More