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
- CREATE TABLE `abc` (
- `uid` int(10) NOT NULL,
- `num1` int(8) NOT NULL,
- `num2` int(8) NOT NULL,
- `num3` int(8) NOT NULL,
- PRIMARY KEY (`uid`)
- ) ENGINE=InnoDB DEFAULT CHARSET=gbk
- CREATE TABLE `abc` (
- `uid` int(10) NOT NULL,
- `num1` int(8) NOT NULL,
- `num2` int(8) NOT NULL,
- `num3` int(8) NOT NULL,
- PRIMARY KEY (`uid`)
- ) 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
- select if((select if(num1>num2,num1,num2))>num3,
(select if(num1>num2,num1,num2)),num3)as num,uid from abc;
- 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
- +-----+-----+
- | num | uid |
- +-----+-----+
- | 3 | 1 |
- | 3 | 2 |
- | 4 | 3 |
- | 5 | 4 |
- | 8 | 5 |
- | 13 | 6 |
- | 56 | 7 |
- +-----+-----+
- 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.