row constructor used to evaluate return of subquery
I have the following table
mysql> desc rt1;
+-------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| val1 | int(11) | YES | | NULL | |
| val2 | int(11) | YES | | NULL | |
| val3 | int(11) | YES | | NULL | |
+-------+---------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysql> select * From rt1;
+----+------+------+------+
| id | val1 | val2 | val3 |
+----+------+------+------+
| 1 | 1 | 2 | 3 |
| 2 | 1 | 2 | 2 |
| 3 | 2 | 2 | 3 |
| 4 | 1 | 3 | 3 |
| 5 | 1 | 2 | 3 |
| 6 | 3 | 3 | 3 |
| 7 | 3 | 2 | 3 |
| 8 | 1 | 1 | 1 |
| 9 | 0 | 1 | 1 |
| 10 | 0 | 3 | 1 |
| 11 | 3 | 0 | 1 |
| 12 | 2 | 0 | 1 |
| 13 | 0 | 3 | 1 |
| 14 | 0 | 2 | 1 |
+----+------+------+------+
14 rows in set (0.00 sec)
When I issue
select * from rt1 where row(val1,val2) >= (select val1, val2 from rt1 where id = 2) ;
I get
+----+------+------+------+
| id | val1 | val2 | val3 |
+----+------+------+------+
| 1 | 1 | 2 | 3 |
| 2 | 1 | 2 | 2 |
| 3 | 2 | 2 | 3 |
| 4 | 1 | 3 | 3 |
| 5 | 1 | 2 | 3 |
| 6 | 3 | 3 | 3 |
| 7 | 3 | 2 | 3 |
| 11 | 3 | 0 | 1 |
| 12 | 2 | 0 | 1 |
+----+------+------+------+
9 rows in set (0.00 sec)
rows with id 11 and 12 shouldn't appear in the result set.
Subject
Written By
Posted
row constructor used to evaluate return of subquery
December 21, 2016 07:06PM
December 21, 2016 08:40PM
December 22, 2016 12:00AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.