![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
2K+ Views
To get dates older than 1 week, you can use the following syntax −select *from yourTableName where yourColumnName < now() - interval 1 week;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table DatesOfOneWeek −> ( −> ArrivalTime datetime −> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table −mysql> insert into DatesOfOneWeek values(date_add(now(), interval 2 week)); Query OK, 1 row affected (0.11 sec) mysql> insert into DatesOfOneWeek values('2018-11-04'); Query OK, 1 row affected ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
494 Views
To implement GROUP BY on two fields and count, let us create a table. The following is the query to create a table −mysql> create table GroupByTwoFieldsDemo −> ( −> Id int, −> Name varchar(200) −> ); Query OK, 0 rows affected (0.53 sec)Let us insert some records in the table −mysql> insert into GroupByTwoFieldsDemo values(1, 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into GroupByTwoFieldsDemo values(10, 'Johnson'); Query OK, 1 row affected (0.16 sec) mysql> insert into GroupByTwoFieldsDemo values(9, 'Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
7K+ Views
To count distinct values, you can use distinct in aggregate function count().The syntax is as follows −select count(distinct yourColumnName) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table DistinctDemo −> ( −> Name varchar(200) −> ); Query OK, 0 rows affected (0.58 sec)For our example, let us insert duplicate records in the table. The query to insert records is as follows −mysql> insert into DistinctDemo values('John'); Query OK, 1 row affected (0.15 sec) mysql> ... Read More
![Rishi Rathor](https://www.tutorialspoint.com/assets/profiles/13563/profile/60_89283-1512714754.jpg)
776 Views
To force MySQL LIKE to be case sensitive with the help of LIKE BINARY, the following is the syntax −select yourColumnName like binary 'anyStringValue' from yourTableName;To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table LikeBinaryDemo −> ( −> Name varchar(200) −> ); Query OK, 0 rows affected (0.58 sec)Now you can insert records with small letters to force the MySQL LIKE to be case sensitive −mysql> insert into LikeBinaryDemo values('john'); Query OK, 1 row affected (0.12 sec)Display the records in the table. The query ... Read More
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
732 Views
To delete under safe mode, you can use the below query −SET SQL_SAFE_UPDATES = 0;To understand the above query, let us create a table. The following is the query to create a table −mysql> create table SafeDeleteDemo −> ( −> Price int −> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table with the help of insert command. The query is as follows −mysql> insert into SafeDeleteDemo values(100); Query OK, 1 row affected (0.11 sec) mysql> insert into SafeDeleteDemo values(200); Query OK, 1 row affected (0.19 sec) mysql> insert into SafeDeleteDemo ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
5K+ Views
You can group month and year with the help of function DATE_FORMAT() in MySQL. The GROUP BY clause is also used.The syntax is as follows −SELECT DATE_FORMAT(yourColumnName, '%m-%Y') from yourTableName GROUP BY MONTH(yourColumnName), YEAR(yourColumnName)DESC;To understand the above concept, let us create a table. The following is the query to create a table −mysql> create table GroupMonthAndYearDemo −> ( −> DueDate datetime −> ); Query OK, 0 rows affected (1.49 sec)Insert records in the table using the following query −mysql> insert into GroupMonthAndYearDemo values(now()); Query OK, 1 row affected (0.11 sec) ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
973 Views
Let’s say we have a database “business” with number of tables. If you want to show only foreign key constraints, then use the following query −mysql> select * −> from information_schema.referential_constraints −> where constraint_schema = 'business';The following is the output displaying only foreign key constraints −+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+ | CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | UNIQUE_CONSTRAINT_CATALOG | UNIQUE_CONSTRAINT_SCHEMA | UNIQUE_CONSTRAINT_NAME | MATCH_OPTION | UPDATE_RULE | DELETE_RULE | TABLE_NAME | REFERENCED_TABLE_NAME | +--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+ | def | business | ConstChild ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
4K+ Views
You can use MONTHNAME() function from MySQL to display Month name from number. The syntax is as follows.SELECT MONTHNAME(STR_TO_DATE(yourColumnName, ’%m’)) as anyVariableName from yourTableName;To understand the above concept, let us first create a table. The query to create a table is as follows.mysql> create table MonthDemo -> ( -> MonthNum int -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into MonthDemo values(1); Query OK, 1 row affected (0.14 sec) mysql> insert into MonthDemo values(2); Query OK, 1 row affected (0.15 sec) mysql> ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
20K+ Views
You can insert NULL value into an int column with a condition i.e. the column must not have NOT NULL constraints. The syntax is as follows.INSERT INTO yourTableName(yourColumnName) values(NULL);To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table InsertNullDemo -> ( -> StudentId int, -> StudentName varchar(100), -> StudentAge int -> ); Query OK, 0 rows affected (0.53 sec)Here is the query to insert NULL whenever you do not pass any value for column. Here this column is StudentAge. MySQL inserts null value by default. The query to ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
You can use BETWEEN clause from MySQL to select records with a particular date and time. The syntax is as follows.select *from AllRecordsFromadate where AdmissionDate between 'yourDateTimeValue1 ' and ''yourDateTimeValue2';To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table AllRecordsFromadate -> ( -> Id int, -> Name varchar(100), -> Age int, -> AdmissionDate datetime -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command. The query to insert records is as follows.mysql> insert into AllRecordsFromadate values(101, 'John', 23, '2018-10-13'); Query OK, ... Read More