The column values of the MySQL database are compared, and the actual application proportion of the logical function IF is still the majority. IF you compare the column values of the MySQL database, if you are curious about the actual operations of the logical function IFOracle, the following articles will unveil the mystery of the function. CREATETABLE 'abc' ('uid' int (10) NOT
The column values of the MySQL database are compared, and the actual application proportion of the logical function IF is still the majority. IF you compare the column values of the MySQL database, if you are curious about the actual operations of the logical function IFOracle, the following articles will unveil the mystery of the function. CREATETABLE 'abc' ('uid' int (10) NOT
The column values of the MySQL database are compared, and the actual application proportion of the logical function IF is still the majority. IF you compare the column values of the MySQL database, if you are curious about the actual operations of the logical function IFOracle, the following articles will unveil the mystery of the function.
Abc table in MySQL database
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.
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 database column-Value Comparison logic function IF. I hope you will get something.