- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How can column data values of a table be compared using MySQL STRCMP() function?
If we want to compare the data values of two columns then we need to provide the name of the columns as arguments of MySQL STRCMP() function. Suppose we have a table named ‘Marks’ which contains the name of the student and their secured marks in different subjects. Now, if we want to know that a particular student has got more or less or equal marks in two subjects then it can be illustrated using STRCMP() function as follows −
Example
mysql> Select Name, STRCMP(Math,Hindi) from student marks WHERE Name = 'Rahul'; +-------+--------------------+ | Name | STRCMP(Math,Hindi) | +-------+--------------------+ | Rahul | 1 | +-------+--------------------+ 1 row in set (0.00 sec)
The query above will compare the marks of Math and Hindi for a student named ‘Rahul’. It is clear from the result set that Rahul secure more marks in Math rather than in Hindi.
- Related Articles
- How number values be used as arguments in MySQL STRCMP() function?
- How to repeat the values stored in a data column of MySQL table?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can I use MySQL INTERVAL() function with a column of a table?
- Which MySQL function can be used to append values of a column with single quotes?
- How MySQL CONCAT() function, applied to the column/s of a table, can be combined with the column/s of other tables?
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?
- How can CONCAT() function be applied on columns of MySQL table?
- What is MySQL STRCMP() function and what would be the output of this function?
- How can we count a number of unique values in a column in MySQL table?
- How can column data be used within MySQL CASE statement?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How can we change the data type of the column in MySQL table?
- How can we apply BIT_LENGTH() function on the column/s of MySQL table?
- Can a number be used to name a MySQL table column?

Advertisements