
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 4218 Articles for MySQLi

278 Views
To remove string from the values EMO1, EMP2, etc., you need to use RIGHT() along with LENGTH(). Let us first create a table −mysql> create table DemoTable1540 -> ( -> EmployeeCode varchar(20) -> ); Query OK, 0 rows affected (0.39 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1540 values('EMP9'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1540 values('EMP4'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1540 values('EMP8'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1540 values('EMP6'); Query OK, 1 row affected (0.12 sec)Display ... Read More

1K+ Views
At first, find the current date and get the difference between joining date and current date using the DATEDIFF().The current date is as follows −mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-10-26 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> JoiningDate varchar(40) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10/10/1998'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('31/12/2010'); Query OK, 1 row affected (0.09 sec) ... Read More

2K+ Views
To combine columns into rows, use UNION ALL. Following is the syntax −Syntaxselect yourColumnName1 from yourTableName union all select yourColumnName2 from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int -> ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 200); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(500, 600); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will ... Read More

109 Views
For faster querying, you need to use MySQL IN(). Let us first create a table −mysql> create table DemoTable1538 -> ( -> ClientId int, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1538 values(101, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1538 values(102, 'Robert'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1538 values(103, 'Bob'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1538 values(104, 'Adam'); Query OK, 1 row affected (0.16 sec)Display ... Read More

80 Views
For this can use DATE_FORMAT() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> PurchaseDate date, -> Amount int -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-10-12', 500); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2018-10-12', 1000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-01-10', 600); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2018-10-12', 600); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More

314 Views
For this, use BETWEEN keyword. Let us first create a table −mysql> create table DemoTable1537 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1537(StudentName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1537(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1537(StudentName) values('Sam'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1537(StudentName) values('Mike'); Query OK, 1 row affected (0.16 sec) mysql> insert into ... Read More

2K+ Views
For this, you can use WHERE clause with multiple LIKE. Let us first create a table −mysql> create table DemoTable1536 -> ( -> Sentence text -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1536 values('I like MySQL database.'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1536 values('Java is an Object Oriented Programming Language'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable1536 values('I only like data structure'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1536 values('MongoDB is ... Read More

616 Views
To order by the first letter, use ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable1535 -> ( -> Value varchar(100) -> ); Query OK, 0 rows affected (2.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1535 values('MySQL is good relational database.'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1535 values('is MySQL easy to lean'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable1535 values('You need to start basic SQL'); Query OK, 1 row affected (0.35 sec)Display all records from the table ... Read More

2K+ Views
Let us first create a table. We have set one of the columns with type TINYINT −mysql> create table DemoTable -> ( -> EmployeeId int, -> isMarried tinyint -> ); Query OK, 0 rows affected (6.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, true); Query OK, 1 row affected (1.94 sec) mysql> insert into DemoTable values(102, false); Query OK, 1 row affected (0.76 sec) mysql> insert into DemoTable values(103, true); Query OK, 1 row affected (1.14 sec) mysql> insert into DemoTable values(104, true); Query OK, 1 row affected (1.22 ... Read More

852 Views
To implement multiple LIKE clauses, the syntax is as follows −select * from yourTableName where yourColumnName1 LIKE ('%yourValue1%' or yourColumnName2 LIKE '%yourValue2%') or (yourColumnName3 LIKE '%yourValue3');Let us first create a table −mysql> create table DemoTable1534 -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20), -> ClientAge int, -> ClientCountryName varchar(20) -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1534(ClientName, ClientAge, ClientCountryName) values('Chris Brown', 29, 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1534(ClientName, ClientAge, ClientCountryName) ... Read More