![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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The binary keyword can be used after WHERE clause to compare a value with exact case sensitive match.The following is an example −Case 1 − Case insensitive matchThe query is as follows −mysql> select 'joHN'='JOHN' as Result;The following is the output −+--------+ | Result | +--------+ | 1 | +--------+ 1 row in set (0.00 sec)In the above sample output, the result is true while we know joHN and JOHN are two different words. This is not a case sensitive match.Case 2 − If you want case sensitive match, use the binary keyword.The query is ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
256 Views
You can get year out of timestamp using YEAR() function. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE YEAR(yourTimestampColumnName)='yourYearValue’';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table getYearOut -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(10), -> yourTimestamp timestamp default current_timestamp, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.56 sec)Insert some records in the table using INSERT command−mysql> insert into getYearOut(Name, yourTimestamp) values('John', now()); Query OK, 1 row affected (0.26 sec) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
97 Views
The CONV() function can be used to convert one base number system to another base system.For Example, The 16 is one base system and 10 is another base system. The 16 base system is hexadecimal and 10 is a decimal.The syntax is as follows −SELECT CAST(CONV('yourColumnName', 16, 10) AS UNSIGNED INTEGER) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table castTypeToBigIntDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Value varchar(100), -> PRIMARY KEY(Id) -> ); Query OK, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To understand the group by with where clause, let us create a table. The query to create a table is as follows −mysql> create table GroupByWithWhereClause -> ( -> Id int NOT NULL AUTO_INCREMENT, -> IsDeleted tinyint(1), -> MoneyStatus varchar(20), -> UserId int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.57 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into GroupByWithWhereClause(IsDeleted, MoneyStatus, UserId) values(0, 'Undone', 101); Query OK, 1 row affected (0.17 sec) mysql> insert into GroupByWithWhereClause(IsDeleted, MoneyStatus, UserId) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
232 Views
You can use a subquery with JOIN condition for this. The syntax is as follows −SELECT yourTablevariableName.* FROM ( SELECT MAX(UNIX_TIMESTAMP(yourDateTimeColumnName)) AS anyAliasName FROM getLatestHour GROUP BY HOUR(UserLoginDateTime) ) yourOuterVariableName JOIN yourTableName yourTablevariableName ON UNIX_TIMESTAMP(yourDateTimeColumnName) = yourOuterVariableName.yourAliasName WHERE DATE(yourDateTimeColumnName) = 'yourDateValue';To understand the above syntax and the result to be achieved, let us create a table. The query to create a table is as follows −mysql> create table getLatestHour -> ( -> UserId int, -> UserName varchar(20), -> UserLoginDateTime ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
247 Views
You can use IFNULL along with ORDER BY clause. The syntax is as follows −SELECT *FROM yourTableName ORDER BY IFNULL(yourColumnName1, yourColumnName2);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table IfNullDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> ProductName varchar(10), -> ProductWholePrice float, -> ProductRetailPrice float, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.19 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into IfNullDemo(ProductName, ProductWholePrice, ProductRetailPrice) values('Product-1', 99.50, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
132 Views
You can use ORDER BY ASC to order timestamp values in ascending order.The following is the syntax without using TIMESTAMP() −SELECT yourTimestampColumnName from yourTableName order by yourTimestampColumnName ASC;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table Timestamp_TableDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> yourTimestamp timestamp -> ); Query OK, 0 rows affected (0.83 sec)Now you can insert some records in the table using insert command. The query is as follows ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
698 Views
To remove the first two characters of all fields, you need to use SUBSTRING() function from MySQL. The syntax is as follows −UPDATE yourTableName SET yourColumnName=SUBSTRING(yourColumnName, 3) WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table RemoveFirstTwoCharacterDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> StringValue varchar(30), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.04 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into RemoveFirstTwoCharacterDemo(StringValue) values('U:100'); Query OK, 1 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
116 Views
To add results from several COUNT queries, you can use the following syntax −SELECT (SELECT COUNT(*) FROM yourTableName1)+ (SELECT COUNT(*) FROM yourTableName2)+ (SELECT COUNT(*) FROM yourTableName3)+ . . . N AS anyAliasName;Let us use three tables in the test database −userssortingstringdemouserlogintableCheck the table records from the table using a select statement. Let’s take 3 sample tables with records.The table records for the first table is as follows −mysql> select *from users;The following is the output −+----+----------+---------------------+ | Id | UserName | UserLastseen | +----+----------+---------------------+ | 1 | Larry | 2019-01-15 02:45:00 | | 2 | Sam ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
If you have spaces between letters then you can use REPLACE() function to remove spaces.The syntax is as follows −UPDATE yourTableName SET yourColumnName=REPLACE(yourColumnName, ’ ‘, ’’);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeSpaceDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserId varchar(20), -> UserName varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.81 sec)Now insert some records in the table using insert ... Read More