- 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
354 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (1.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable(FirstName, LastName) values('Carol', 'Miller'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable(FirstName, LastName) values('John', 'Doe'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output ... Read More
3K+ Views
To suppress warnings, set SQL_NOTES=0. Let us see an example.At first, we will set SQL_NOTES to 1 −mysql> SET sql_notes = 1; Query OK, 0 rows affected (0.00 sec)Now, let us drop a table which does not exist. As you can see a warning message is now visible −mysql> drop table if exists web.DemoTable; Query OK, 0 rows affected, 1 warning (0.07 sec)To look at the above warning message, you need to just use the SHOW WARNINGS command −mysql> show warnings;This will produce the following output displaying the warning message −+-------+------+-----------------------------------+ | Level | Code | Message ... Read More
131 Views
For custom order, use ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable ( Title varchar(100) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Java_1+'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('MySQL_23+'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('MongoDB++'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('C++_23'); 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
79 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), Score int ); Query OK, 0 rows affected (1.10 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Score) values('John', 45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name, Score) values('Chris', null); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name, Score) values('David', null); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Name, Score) values('Bob', 1); Query OK, 1 row affected (0.11 sec)Display all records from ... Read More
557 Views
For this, you can use the INTERVAL 7 day concept. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, AdmissionDate datetime ); Query OK, 0 rows affected (0.83 sec)Note − Let’s say the current date is 2019-08-23.Insert some records in the table using insert command −mysql> insert into DemoTable(AdmissionDate) values('2019-01-23'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(AdmissionDate) values('2019-08-15'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable(AdmissionDate) values('2019-08-16'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(AdmissionDate) values('2019-08-24'); Query OK, 1 ... Read More
91 Views
Let us first create a table −mysql> create table DemoTable ( value1 int, value2 int, value3 int ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(20, 40, null); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(40, 40, null); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(null, null, null); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------+--------+--------+ | value1 | value2 ... Read More
98 Views
For this, use ORDER BY with a modulus operator. Let us first create a table −mysql> create table DemoTable ( StudentId int, StudentName varchar(100) ); Query OK, 0 rows affected (1.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(101, 'Robert'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.94 sec) mysql> insert into DemoTable values(103, 'Mike'); Query OK, 1 row affected (0.23 sec)Display all records from the table using ... Read More
298 Views
You can use an aggregate function SUM() along with IF(). Let us first create a table −mysql> create table DemoTable ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (2.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable values('John', 'Doe'); Query OK, 1 row affected (1.38 sec) mysql> insert into DemoTable values('Bob', 'Doe'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Sam', ... Read More
560 Views
You can use REGEXP. Let us first create a table −mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (1.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JohnSmith'); Query OK, 1 row affected (0.73 sec) mysql> insert into DemoTable values('John Doe'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('DavidMiller'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Carol Taylor'); Query OK, 1 row affected (0.27 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ... Read More
3K+ Views
To fetch multiple values wit LIKE, use the LIKE operator along with OR operator. Let us first create a table −mysql> create table DemoTable1027 ( Id int, Name varchar(100) ); Query OK, 0 rows affected (1.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1027 values(100, 'John'); Query OK, 1 row affected (0.72 sec) mysql> insert into DemoTable1027 values(20, 'Chris'); Query OK, 1 row affected (0.56 sec) mysql> insert into DemoTable1027 values(200, 'Robert'); Query OK, 1 row affected (0.84 sec) mysql> insert into DemoTable1027 values(400, 'Mike'); Query OK, 1 row affected (0.47 sec)Display all ... Read More