- 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)
316 Views
For this, you can use UNIQUE KEY. Let us first create a table −mysql> create table DemoTable1553 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeSalary int -> ); Query OK, 0 rows affected (0.47 sec)Here is the query to add unique key −mysql> alter table DemoTable1553 add unique(EmployeeSalary); Query OK, 0 rows affected (0.53 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable1553(EmployeeName, EmployeeSalary) values('Chris', 45000); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1553(EmployeeName, EmployeeSalary) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
70 Views
Use single quotes on string input value. If there is an identifier like table name or column name, then do not use single quotes (use backticks).Let us first create a table −mysql> create table DemoTable1552 -> ( -> `key` int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1552 values(101, 'Chris'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1552 values(102, 'David'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1552 values(103, 'Mike'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
342 Views
Use FORMAT() in MySQL to display USD currency records in the correct form. Let us first create a table −mysql> create table DemoTable -> ( -> Amount DECIMAL(15, 4) -> ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(90948484); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1000000000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(1535353536); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(773646463); Query OK, 1 row affected (0.20 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
331 Views
For this, you can use ORDER BY clause along with LIMIT. Let us first create a table −mysql> create table DemoTable1551 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1551(EmployeeName) values('Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1551(EmployeeName) values('Robert'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1551(EmployeeName) values('Mike'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1551(EmployeeName) values('Sam'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
189 Views
To search from a comma-separated column, use the FIND_IN_SET() method. Let us first create a table −mysql> create table DemoTable -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('41, 14, 94'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('64, 84, 94'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('44, 74, 103, 104'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('904, 1004, 1444, 1544'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
157 Views
To maintain the custom order of IDs, use ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable1550 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1550 values(101, 'Chris'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1550 values(110, 'Bob'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable1550 values(105, 'Carol'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1550 values(109, 'Mike'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
317 Views
For this, you can use the INSERT INTO SELECT statement. To format the date, use the DATE_FORMAT() function. Let us first create a table −mysql> create table DemoTable -> ( -> DateOfJoining datetime, -> JoiningDate text -> ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(DateOfJoining) values('2019-10-26 13:52:10'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(DateOfJoining) values('2018-12-31 15:20:40'); Query OK, 1 row affected (0.16 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)
209 Views
There is no difference between show index, show indexes and show keys. They have similar meaning.Let us first create a table −mysql> create table DemoTable1549 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)Following is the query to create an index −mysql> create index name_index1 on DemoTable1549(EmployeeName); Query OK, 0 rows affected (0.41 sec) Records: 0 Duplicates: 0 Warnings: 0Following is the query for SHOW INDEX −mysql> show index from DemoTable1549;This will produce the following output −+---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
734 Views
To fetch records from comma separated values, use MySQL FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1548 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> ArrayListOfMarks varchar(100) -> ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('Chris', '56, 78, 90, 87'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('Bob', '90, 78, 65'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('David', '91, 34, 56, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
141 Views
For this, you need to compare and find the difference between the current date and the result date of students. This can be done with AND operator along with DATEDIFF().Let us first create a table −mysql> create table DemoTable1547 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentMarks int, -> StudentResultDeclareDate datetime -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1547(StudentName, StudentMarks, StudentResultDeclareDate) values('Chris', 56, '2019-10-13 13:00:00') -> ; Query OK, 1 row affected (0.16 ... Read More