Description of the actual application code for MySQL column Value Comparison

Source: Internet
Author: User
The following articles mainly describe MySQL column Value Comparison and detailed introduction of related logical functions. This article mainly uses code to introduce the actual operation of MySQL column value comparison, the specific content of this article is as follows. I hope it will help you in this regard. How to evaluate expressions, such as the evalSql code CREATETABL in Javascript

The following articles mainly describe MySQL column Value Comparison and detailed introduction of related logical functions. This article mainly uses code to introduce the actual operation of MySQL column value comparison, the specific content of this article is as follows. I hope it will help you in this regard. How to evaluate expressions, such as the eval SQL code CREATETABL in Javascript

The following articles mainly describe MySQL column Value Comparison and detailed introduction of related logical functions. This article mainly uses code to introduce the actual operation of MySQL column value comparison, the specific content of this article is as follows. I hope it will help you in this regard.

How to evaluate expressions, such as eval in Javascript

SQL code

 
 
  1. CREATE TABLE `abc` (
  2. `uid` int(10) NOT NULL,
  3. `num1` int(8) NOT NULL,
  4. `num2` int(8) NOT NULL,
  5. `num3` int(8) NOT NULL,
  6. PRIMARY KEY (`uid`)
  7. ) ENGINE=InnoDB DEFAULT CHARSET=gbk
  8. CREATE TABLE `abc` (
  9. `uid` int(10) NOT NULL,
  10. `num1` int(8) NOT NULL,
  11. `num2` int(8) NOT NULL,
  12. `num3` int(8) NOT NULL,
  13. PRIMARY KEY (`uid`)
  14. ) ENGINE=InnoDB DEFAULT CHARSET=gbk

Task: Compares the data in each column and displays the uid and maximum data columns.

MySQL column Value Comparison logical function IF: method:

SQL code

 
 
  1. select if((select if(num1>num2,num1,num2))>num3,
    (select if(num1>num2,num1,num2)),num3)as num,uid from abc;
  2. select if((select if(num1>num2,num1,num2))>num3,
    (select if(num1>num2,num1,num2)),num3)as num,uid from abc;

In this way, the writing is not good, and there are no good methods for comparison.

The result is as follows:

Java code

 
 
  1. +-----+-----+
  2. | num | uid |
  3. +-----+-----+
  4. | 3 | 1 |
  5. | 3 | 2 |
  6. | 4 | 3 |
  7. | 5 | 4 |
  8. | 8 | 5 |
  9. | 13 | 6 |
  10. | 56 | 7 |
  11. +-----+-----+
  12. 7 rows in set

The above content is an introduction to the MySQL column-Value Comparison logic function IF. I hope you will get something.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.