- 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)
616 Views
To set conditions in a stored procedure, use IF...ELSE in MySQL. Following is the syntax for if-else −IF yourCondition then yourStatement1, ELSE yourStatement2, END IF;Let us implement the above syntax in a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE IF_ELSE_DEMO(IN value int) -> BEGIN -> SET @val=value; -> IF @val > 10 then -> select concat(@val, ' is greater than 10'); -> ELSE -> select concat(@val, ' is less than 10 '); -> END ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
344 Views
To get string as date, use STR_TO_DATE() method. Let us first create a table −mysql> create table DemoTable1445 -> ( -> AdmissionDate varchar(20) -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1445 values('01.10.2019'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1445 values('31.12.2018'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1445 values('01.02.2017'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select −mysql> select * from DemoTable1445;This will produce the following output −+---------------+ | AdmissionDate | ... Read More
![Mahesh Parahar](https://www.tutorialspoint.com/assets/profiles/127878/profile/60_2277600-1655382864.jpg)
7K+ Views
Both MySQL and SQL Server, both are relational database management systems or RDBMS. MySQL is open source and is free to use whereas SQL Server is licensed product of Microsoft.Following are the important differences between MySQL and SQL Server.Sr. No.KeyMySQLSQL Server1Owned/Developed ByMySQL is owned by Oracle.SQL Server is developed by Microsoft.2Language supportMySql supports programming languages like C++, Java and has running support for Perl, TCL and Haskel.SQL Server supports programming languages like C++, Java, Ruby, Visual Basic, Delphi, R.3Storage SpaceMySql needs less amount of operational storage space.SQL Server needs large amount of operational storage space.4Query CancellationMySql does not support midway ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, use BETWEEN keyword. Let us first create a −mysql> create table DemoTable1444 -> ( -> Value int, -> PurchaseDate datetime -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert −mysql> insert into DemoTable1444 values(40, '2019-01-10'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1444 values(100, '2019-10-03'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1444 values(170, '2019-11-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1444 values(70, '2018-12-05'); Query OK, 1 row affected (0.11 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
46 Views
You need to use GROUP BY clause. Let us first create a −mysql> create table DemoTable1443 -> ( -> StudentId int, -> StudentScore int -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert −mysql> insert into DemoTable1443 values(100, 78); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1443 values(101, 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1443 values(100, 88); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1443 values(101, 97); Query OK, 1 row affected (0.12 sec)Display all records from the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
202 Views
Let us first create a −mysql> create table DemoTable1442 -> ( -> DueTime time -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert −mysql> insert into DemoTable1442 values('00:08:00'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1442 values('00:04:00'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1442 values('12:55:00'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select −mysql> select * from DemoTable1442;This will produce the following output −+----------+ | DueTime | +----------+ | 00:08:00 | | 00:04:00 | | 12:55:00 | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
52 Views
MySQL will implicitly convert the column into a number. Following is the syntax −select * from yourTableName order by yourColumnName*1;Let us first create a −mysql> create table DemoTable1441 -> ( -> Id varchar(30) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert −mysql> insert into DemoTable1441 values('301'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1441 values('23'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1441 values('345'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1441 values('10'); Query OK, 1 row affected (0.23 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
Use DEFAULT keyword in MySQL to set default value to NULL. Let us first create a −mysql> create table DemoTable1440 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) DEFAULT NULL, -> StudentAge int DEFAULT NULL -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command. For values left blank, the default gets inserted −mysql> insert into DemoTable1440(StudentName, StudentAge) values('Chris', 21); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1440 values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1440(StudentName) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
189 Views
For specific value, use FIND_IN_SET(). Let us first create a −mysql> create table DemoTable1439 -> ( -> CountryId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CountryCode varchar(20) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert −mysql> insert into DemoTable1439(CountryCode) values('1022_US, 7894_UK'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1439(CountryCode) values('6567_AUS, 7894_UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1439(CountryCode) values('6567_AUS'); Query OK, 1 row affected (0.09 sec)Display all records from the table using select −mysql> select * from DemoTable1439;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, you can use JSON data type from MySQL. Let us first create a −mysql> create table DemoTable1438 -> ( -> EmployeeDetails json -> ); Query OK, 0 rows affected (5.97 sec)Insert some records in the table using insert −mysql> insert into DemoTable1438 values('[{"EmployeeId":"EMP-101","EmployeeName":"Chris"},{"EmployeeId":"EMP-102","EmployeeName":"David"},{"EmployeeId":"EMP-103","EmployeeName":"Sam"}]'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select −mysql> select * from DemoTable1438;This will produce the following output −+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | EmployeeDetails | +------------------------------------------------------------------------------------------------------------------------------------------------------------+ | [{"EmployeeId": "EMP-101", "EmployeeName": "Chris"}, {"EmployeeId": "EMP-102", "EmployeeName": "David"}, {"EmployeeId": "EMP-103", "EmployeeName": "Sam"}] | +------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)