- 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
616 Views
Let us first create a table −mysql> create table DemoTable ( Value varchar(100) ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('100'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(''); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('200'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values(null); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-------+ | Value | +-------+ ... Read More
115 Views
Use BETWEEN to find the logins between two dates. Let us first create a table −mysql> create table DemoTable ( Login datetime ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-08-10'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('2019-08-12'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-08-20'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-08-24'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will ... Read More
452 Views
Let us first create a table −mysql> create table DemoTable1045 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) )AUTO_INCREMENT=100; Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1045(FirstName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1045(FirstName) values('Chris'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1045(FirstName) values('Robert'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1045(FirstName) values('Mike'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1045(FirstName) values('Adam'); Query OK, 1 row affected (0.08 sec)Display all records ... Read More
104 Views
For this, use ORDER BY LIKE operator. Let us first create a table −mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Jace'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.09 sec) mysql> insert into ... Read More
353 Views
Use MAX() along with subquery for this Here, MAX() is used to get the maximum amount. Let us first create a table −mysql> create table DemoTable ( ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ProductName varchar(100), ProductAmount int ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ProductName, ProductAmount) values('Product-1', 60); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ProductName, ProductAmount) values('Product-2', 40); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(ProductName, ProductAmount) values('Product-3', 75); Query OK, 1 row affected (0.15 sec) mysql> ... Read More
244 Views
To compare the first date with the last date, use TIME_TO_SEC() along with MAX() and MIN(). Let us first create a table −mysql> create table DemoTable ( UserName varchar(100), UserPostDatetime datetime ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', '2019-08-24 11:10:00'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Adam', '2019-08-24 11:20:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Adam', '2019-08-24 11:50:00'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> ... Read More
572 Views
Let us first create a table −mysql> create table DemoTable ( Id int, Name varchar(100) ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(110, 'David'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(120, 'Robert'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(130, 'Mike'); 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 ... Read More
210 Views
For this, use the CASE WHEN statement. Let us first create a table −mysql> create table DemoTable1040 ( Value1 int, Value2 int, Value3 int ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1040 values(10, 30, 1); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1040 values(40, 20, 50); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1040 values(80, 90, 100); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable1040;This will produce the ... Read More
260 Views
To get the left substring, use LEFT() along with substring_index(). For example, let’s say the file path is −“/MyFile/JavaProgram/Hello.java “Here, we will see how to display the entire file path except for the file name i.e. −/MyFile/JavaProgram/Let us first create a table −mysql> create table DemoTable ( FileLocation text ); Query OK, 0 rows affected (0.57 secInsert some records in the table using insert command −mysql> insert into DemoTable values('/MyFile/JavaProgram/Hello.java'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('/C/AllPrograms/animation.gif'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('/E/FavFile/ChatProgram.java'); Query OK, 1 row affected ... Read More
222 Views
To get the fourth-highest value, use LIMIT OFFSET along with ORDER BY. Let us first create a table −mysql> create table DemoTable ( Amount int ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(980); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(670); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(890); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(995); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(198); Query OK, 1 row affected ... Read More