- 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)
234 Views
For this, you can use the CASE statement. To sort, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. Some records have certain last string like -D, etc −mysql> insert into DemoTable(ClientName) values('Mike'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(ClientName) values('John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable(ClientName) values('John-D'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
202 Views
Let us first create a table −mysql> create table DemoTable1546 -> ( -> Number varchar(20) -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1546 values('145 78 90'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1546 values('89 789 564 903'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1546 values('1345 7894 866 653534'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable1546;This will produce the following output −+----------------------+ | Number ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
149 Views
To understand, let us create a stored procedure. Here, we have 2 select statements in the stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE select_statement() -> BEGIN -> SELECT "HI" AS `FIRST VALUE`; -> SELECT "HELLO" AS `SECOND VALUE`; -> END -> // Query OK, 0 rows affected (0.09 sec) mysql> DELIMITER ;Call the stored procedure using CALL command −mysql> CALL select_statement();This will produce the following output −+-------------+ | FIRST VALUE | +-------------+ | HI | +-------------+ 1 row in set (0.00 sec) +--------------+ | SECOND VALUE | +--------------+ | HELLO | +--------------+ 1 row in set (0.01 sec) Query OK, 0 rows affected (0.01 sec)
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
744 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name text -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John [John] Smith'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('[Carol] Carol Taylor'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('David [Miller] Miller'); 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−+-----------------------+ | Name ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
143 Views
For conditions, use CASE statement in MySQL. Let us first create a table −mysql> create table DemoTable1545 -> ( -> Id int, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (1.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1545 values(1, 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1545 values(2, 'Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1545 values(3, 'Bob'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select * from DemoTable1545;This will produce ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
111 Views
Let us first create a table −mysql> create table DemoTable1544 -> ( -> Id int , -> Name varchar(20) -> ); Query OK, 0 rows affected (2.47 sec)Insert some records in the table using insert command. We have inserted multiple data using SET clause −mysql> insert into DemoTable1544 set Id=101, Name='John Doe'; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1544 set Id=102, Name='Adam Smith'; Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1544 set Id=103, Name='Chris Brown'; Query OK, 1 row affected (0.12 sec)Display all records from the table using select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
313 Views
Let us first create a table −mysql> create table DemoTable -> ( -> EmailId varchar(30) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John123@example.com'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('John123@gmail.com'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('John123@yahoo.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('John123@example.com'); Query OK, 1 row affected (0.10 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)
604 Views
For this, use aggregate function COUNT(*). Let us first create a table −mysql> create table DemoTable1543 -> ( -> Value1 int, -> Value2 int -> ); Query OK, 0 rows affected (1.36 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1543 values(57, 60); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable1543 values(60, 68); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1543 values(90, 98); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable1543 values(98, 90); 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)
84 Views
For this, you can use GROUP_CONCAT(), COUNT() along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable -> ( -> CompanyId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CompanyName varchar(20) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CompanyName) values('Amazon'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(CompanyName) values('Google'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(CompanyName) values('Google'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(CompanyName) values('Microsoft'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
444 Views
You can use the CEIL() function from MySQL. Let us first create a table. Here, we have taken the first column as VARCHAR −mysql> create table DemoTable -> ( -> Value varchar(20), -> UpdateValue int -> ); Query OK, 0 rows affected (1.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values('100'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Value) values('false'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Value) values('true'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(Value) values('1'); Query OK, 1 ... Read More