How can I use MySQL IN() function to compare row constructors?


We can also use IN() function to compare row constructors. Consider the following example to make it clearer −

mysql> Select (10,2) IN ((5,10),(10,2),(2,10),(100,100));
+--------------------------------------------+
| (10,2) IN ((5,10),(10,2),(2,10),(100,100)) |
+--------------------------------------------+
| 1                                          |
+--------------------------------------------+
1 row in set (0.00 sec)

mysql> Select (10,2) IN ((5,10),(2,10),(100,100));
+-------------------------------------+
| (10,2) IN ((5,10),(2,10),(100,100)) |
+-------------------------------------+
| 0                                   |
+-------------------------------------+
1 row in set (0.00 sec)

Updated on: 22-Jun-2020

63 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements