

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How number values be used as arguments in MySQL STRCMP() function?
- How can we use MySQL EXPORT_SET() function with column of a table?
- Which MySQL function can be used to append values of a column with single quotes?
- How can I use MySQL INTERVAL() function with a column of a table?
- How can CONCAT() function be applied on columns of MySQL table?
- How to repeat the values stored in a data column of MySQL table?
- Can a number be used to name a MySQL table column?
- What is MySQL STRCMP() function and what would be the output of this function?
- How MySQL CONCAT() function, applied to the column/s of a table, can be combined with the column/s of other tables?
- How can column data be used within MySQL CASE statement?
- How can we use MySQL POWER() function with the column’s data values?
- How can we count a number of unique values in a column in MySQL table?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How to use REPLACE() function with column’s data of MySQL table?
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?
Advertisements