github.com/matrixorigin/matrixone@v0.7.0/test/distributed/cases/subquery/subquery-with-in.result (about)

     1  SELECT 1 IN (SELECT 1);
     2  1 IN (SELECT 1)
     3  true
     4  SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
     5  1
     6  1
     7  SELECT 1 FROM (SELECT 1 as a) b WHERE 1 not IN (SELECT (SELECT a));
     8  1
     9  SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id);
    10  id
    11  1
    12  SELECT * FROM (SELECT 1) a  WHERE 1 IN (SELECT 1,1);
    13  invalid input: subquery returns more than 1 column
    14  SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
    15  SQL parser error: No tables used
    16  SELECT ((0,1) NOT IN (SELECT NULL,1)) IS NULL;
    17  ((0,1) NOT IN (SELECT NULL,1)) IS NULL
    18  true
    19  drop table if exists t1;
    20  drop table if exists t2;
    21  drop table if exists t3;
    22  create table t1 (a int);
    23  create table t2 (a int, b int);
    24  create table t3 (a int);
    25  create table t4 (a int not null, b int not null);
    26  insert into t1 values (2);
    27  insert into t2 values (1,7),(2,7);
    28  insert into t4 values (4,8),(3,8),(5,9);
    29  insert into t2 values (100, 5);
    30  select * from t3 where a in (select b from t2);
    31  a
    32  select * from t3 where a in (select b from t2 where b > 7);
    33  a
    34  select * from t3 where a not in (select b from t2);
    35  a
    36  SELECT 0 IN (SELECT 1 FROM t1 a);
    37  0 IN (SELECT 1 FROM t1 a)
    38  false
    39  select * from t3 where a in (select a,b from t2);
    40  invalid input: subquery returns more than 1 column
    41  select * from t3 where a in (select * from t2);
    42  invalid input: subquery returns more than 1 column
    43  drop table if exists t1;
    44  drop table if exists t2;
    45  drop table if exists t3;
    46  create table t1 (s1 char(5), index s1(s1));
    47  create table t2 (s1 char(5), index s1(s1));
    48  insert into t1 values ('a1'),('a2'),('a3');
    49  insert into t2 values ('a1'),('a2');
    50  select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
    51  s1	s1 NOT IN (SELECT s1 FROM t2)
    52  a1	false
    53  a2	false
    54  a3	true
    55  select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
    56  s1	s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')
    57  a1	false
    58  a2	true
    59  a3	true
    60  drop table if exists t1;
    61  drop table if exists t2;
    62  create table t1(val varchar(10));
    63  insert into t1 values ('aaa'), ('bbb'),('eee'),('mmm'),('ppp');
    64  select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where w2.val like 'm%') and w1.val in (select w3.val from t1 as w3 where w3.val like 'e%');
    65  count(*)
    66  0
    67  DROP TABLE IF EXISTS t1;
    68  create table t1 (id int not null, text varchar(20) not null default '', primary key (id));
    69  insert into t1 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text11'), (12, 'text12');
    70  select * from t1 where id not in (select id from t1 where id < 8);
    71  id	text
    72  8	text8
    73  9	text9
    74  10	text10
    75  11	text11
    76  12	text12
    77  drop table if exists t1;
    78  drop table if exists t2;
    79  drop table if exists t3;
    80  CREATE TABLE t1 (a int);
    81  CREATE TABLE t2 (a int, b int);
    82  CREATE TABLE t3 (b int NOT NULL);
    83  INSERT INTO t1 VALUES (1), (2), (3), (4);
    84  INSERT INTO t2 VALUES (1,10), (3,30);
    85  select * from t1 where t1.a in (SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.a=t1.a);
    86  a
    87  1
    88  2
    89  3
    90  4
    91  SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10;
    92  a	b	b
    93  SELECT * FROM t1 WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10);
    94  a
    95  1
    96  2
    97  3
    98  4
    99  drop table if exists t1;
   100  drop table if exists t2;
   101  drop table if exists t3;
   102  CREATE TABLE t1(a int, INDEX (a));
   103  INSERT INTO t1 VALUES (1), (3), (5), (7);
   104  INSERT INTO t1 VALUES (NULL);
   105  CREATE TABLE t2(a int);
   106  INSERT INTO t2 VALUES (1),(2),(3);
   107  SELECT a, a IN (SELECT a FROM t1) FROM t2;
   108  a	a IN (SELECT a FROM t1)
   109  1	true
   110  2	null
   111  3	true
   112  drop table if exists t1;
   113  drop table if exists t2;
   114  drop table if exists t3;
   115  CREATE table t1 ( c1 int );
   116  INSERT INTO t1 VALUES ( 1 );
   117  INSERT INTO t1 VALUES ( 2 );
   118  INSERT INTO t1 VALUES ( 3 );
   119  CREATE TABLE t2 ( c2 int );
   120  INSERT INTO t2 VALUES ( 1 );
   121  INSERT INTO t2 VALUES ( 4 );
   122  INSERT INTO t2 VALUES ( 5 );
   123  SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN (1);
   124  c1	c2
   125  1	1
   126  SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
   127  c1	c2
   128  1	1
   129  drop table if exists t1;
   130  drop table if exists t2;
   131  DROP TABLE IF EXISTS c;
   132  CREATE TABLE `c` (
   133  `int_nokey` int(11) NOT NULL,
   134  `int_key` int(11) NOT NULL
   135  );
   136  INSERT INTO `c` VALUES (9,9), (0,0), (8,6), (3,6), (7,6), (0,4),
   137  (1,7), (9,4), (0,8), (9,4), (0,7), (5,5), (0,0), (8,5), (8,7),
   138  (5,2), (1,8), (7,0), (0,9), (9,5);
   139  SELECT * FROM c WHERE `int_key` IN (SELECT `int_nokey`);
   140  int_nokey	int_key
   141  9	9
   142  0	0
   143  5	5
   144  0	0
   145  DROP TABLE IF EXISTS c;
   146  drop table if exists t1;
   147  drop table if exists t2;
   148  CREATE TABLE t1(c INT);
   149  CREATE TABLE t2(a INT, b INT);
   150  INSERT INTO t2 VALUES (1, 10), (2, NULL);
   151  INSERT INTO t1 VALUES (1), (3);
   152  SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10);
   153  a	b
   154  drop table if exists t1;
   155  drop table if exists t2;
   156  CREATE TABLE t1 (
   157  a1 char(8) DEFAULT NULL,
   158  a2 char(8) DEFAULT NULL
   159  );
   160  CREATE TABLE t2 (
   161  b1 char(8) DEFAULT NULL,
   162  b2 char(8) DEFAULT NULL
   163  );
   164  INSERT INTO t1 VALUES
   165  ('1 - 00', '2 - 00'),('1 - 01', '2 - 01'),('1 - 02', '2 - 02');
   166  INSERT INTO t2 VALUES
   167  ('1 - 01', '2 - 01'),('1 - 01', '2 - 01'),
   168  ('1 - 02', '2 - 02'),('1 - 02', '2 - 02'),('1 - 03', '2 - 03');
   169  SELECT * FROM t2 WHERE b1 NOT IN ('1 - 00', '1 - 01', '1 - 02');
   170  b1	b2
   171  1 - 03	2 - 03
   172  drop table if exists t1;
   173  drop table if exists t2;
   174  drop table if exists t1;
   175  drop table if exists t2;
   176  drop table if exists t3;
   177  drop table if exists t4;
   178  CREATE TABLE `t1` (
   179  `numeropost` int(8) unsigned NOT NULL,
   180  `maxnumrep` int(10) unsigned NOT NULL default 0,
   181  PRIMARY KEY  (`numeropost`)
   182  ) ;
   183  INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
   184  CREATE TABLE `t2` (
   185  `mot` varchar(30) NOT NULL default '',
   186  `topic` int(8) unsigned NOT NULL default 0,
   187  `dt` date,
   188  `pseudo` varchar(35) NOT NULL default '',
   189  PRIMARY KEY  (`topic`)
   190  ) ;
   191  INSERT INTO t2 (mot,topic,dt,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
   192  SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
   193  mot	topic	dt	pseudo
   194  joce	40143	2002-10-22	joce
   195  joce	43506	2002-10-22	joce
   196  SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
   197  mot	topic	dt	pseudo
   198  SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
   199  mot	topic	dt	pseudo
   200  SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
   201  mot	topic	dt	pseudo
   202  joce	40143	2002-10-22	joce
   203  SELECT * from t2 where topic NOT IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
   204  mot	topic	dt	pseudo
   205  joce	43506	2002-10-22	joce
   206  SELECT * FROM t2 WHERE mot IN (SELECT 'joce');
   207  mot	topic	dt	pseudo
   208  joce	40143	2002-10-22	joce
   209  joce	43506	2002-10-22	joce
   210  drop table if exists t1;
   211  drop table if exists t2;
   212  create table t1 (a int);
   213  create table t2 (a int);
   214  insert into t1 values (1),(2);
   215  insert into t2 values (0),(1),(2),(3);
   216  select a from t2 where a in (select a from t1);
   217  a
   218  1
   219  2
   220  select a from t2 having a in (select a from t1);
   221  SQL syntax error: column "t2.a" must appear in the GROUP BY clause or be used in an aggregate function
   222  drop table if exists t1;
   223  drop table if exists t2;
   224  create table t1 (oref int, grp int, ie int) ;
   225  insert into t1 (oref, grp, ie) values(1, 1, 1),(1, 1, 1), (1, 2, NULL),(2, 1, 3),(3, 1, 4),(3, 2, NULL);
   226  create table t2 (oref int, a int);
   227  insert into t2 values(1, 1),(2, 2),(3, 3), (4, NULL),(2, NULL);
   228  create table t3 (a int);
   229  insert into t3 values (NULL), (NULL);
   230  select a, oref, a in (select max(ie) from t1 where oref=t2.oref group by grp) Z from t2;
   231  a	oref	Z
   232  1	1	true
   233  2	2	false
   234  3	3	null
   235  null	4	false
   236  null	2	null
   237  select a, oref from t2 where a in (select max(ie) from t1 where oref=t2.oref group by grp);
   238  a	oref
   239  1	1
   240  select a, oref, a in (
   241  select max(ie) from t1 where oref=t2.oref group by grp union
   242  select max(ie) from t1 where oref=t2.oref group by grp
   243  ) Z from t2;
   244  a	oref	z
   245  1	1	true
   246  2	2	false
   247  3	3	null
   248  null	4	false
   249  null	2	null
   250  select a in (select max(ie) from t1 where oref=4 group by grp) from t3;
   251  a in (select max(ie) from t1 where oref=4 group by grp)
   252  false
   253  false
   254  drop table if exists t1;
   255  drop table if exists t2;
   256  drop table if exists t3;
   257  create table t1 (a int, oref int);
   258  insert into t1 values(1, 1),(1, NULL),(2, 3),(2, NULL),(3, NULL);
   259  create table t2 (a int, oref int);
   260  insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4);
   261  select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
   262  oref	a	Z
   263  1	1	true
   264  2	2	false
   265  3	null	null
   266  4	null	false
   267  select oref, a from t2 where a in (select a from t1 where oref=t2.oref);
   268  oref	a
   269  1	1
   270  delete from t2;
   271  insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0);
   272  select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
   273  oref	a	Z
   274  0	null	false
   275  0	null	false
   276  0	null	false
   277  0	null	false
   278  drop table if exists t1;
   279  drop table if exists t2;
   280  drop table if exists t1;
   281  drop table if exists t2;
   282  CREATE TABLE t2 (id int(11) default NULL);
   283  INSERT INTO t2 VALUES (1),(2);
   284  SELECT * FROM t2 WHERE id IN (SELECT 1);
   285  id
   286  1
   287  SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
   288  'union' will be supported in future version.
   289  SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
   290  id
   291  2
   292  SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
   293  'union' will be supported in future version.
   294  SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
   295  'union' will be supported in future version.
   296  SELECT * FROM t2 WHERE id NOT IN (SELECT 5 UNION SELECT 2);
   297  'union' will be supported in future version.
   298  drop table if exists t1;
   299  drop table if exists t2;
   300  create table t1 (a int);
   301  insert into t1 values (1),(2),(3);
   302  select 1 IN (SELECT * from t1);
   303  1 IN (SELECT * from t1)
   304  true
   305  select 10 IN (SELECT * from t1);
   306  10 IN (SELECT * from t1)
   307  false
   308  select NULL IN (SELECT * from t1);
   309  NULL IN (SELECT * from t1)
   310  null
   311  update t1 set a=NULL where a=2;
   312  select 1 IN (SELECT * from t1);
   313  1 IN (SELECT * from t1)
   314  true
   315  select 3 IN (SELECT * from t1);
   316  3 IN (SELECT * from t1)
   317  true
   318  select 10 IN (SELECT * from t1);
   319  10 IN (SELECT * from t1)
   320  null
   321  DROP TABLE IF EXISTS t1;
   322  create table t1 (a varchar(20));
   323  insert into t1 values ('A'),('BC'),('DEF');
   324  select 'A' IN (SELECT * from t1);
   325  'A' IN (SELECT * from t1)
   326  true
   327  select 'XYZS' IN (SELECT * from t1);
   328  'XYZS' IN (SELECT * from t1)
   329  false
   330  select NULL IN (SELECT * from t1);
   331  NULL IN (SELECT * from t1)
   332  null
   333  update t1 set a=NULL where a='BC';
   334  select 'A' IN (SELECT * from t1);
   335  'A' IN (SELECT * from t1)
   336  true
   337  select 'DEF' IN (SELECT * from t1);
   338  'DEF' IN (SELECT * from t1)
   339  true
   340  select 'XYZS' IN (SELECT * from t1);
   341  'XYZS' IN (SELECT * from t1)
   342  null
   343  DROP TABLE IF EXISTS t1;
   344  create table t1 (a float);
   345  insert into t1 values (1.5),(2.5),(3.5);
   346  select 1.5 IN (SELECT * from t1);
   347  1.5 IN (SELECT * from t1)
   348  true
   349  select 10.5 IN (SELECT * from t1);
   350  10.5 IN (SELECT * from t1)
   351  false
   352  select NULL IN (SELECT * from t1);
   353  NULL IN (SELECT * from t1)
   354  null
   355  update t1 set a=NULL where a=2.5;
   356  select 1.5 IN (SELECT * from t1);
   357  1.5 IN (SELECT * from t1)
   358  true
   359  select 3.5 IN (SELECT * from t1);
   360  3.5 IN (SELECT * from t1)
   361  true
   362  select 10.5 IN (SELECT * from t1);
   363  10.5 IN (SELECT * from t1)
   364  null
   365  drop table if exists t1;
   366  drop table if exists t2;
   367  CREATE TABLE t1 (a int(11) NOT NULL default 0, PRIMARY KEY  (a));
   368  CREATE TABLE t2 (a int(11) default 0, INDEX (a));
   369  CREATE TABLE t3 (a int(11) default 0);
   370  INSERT INTO t3 VALUES (1),(2),(3);
   371  INSERT INTO t1 VALUES (1),(2),(3),(4);
   372  INSERT INTO t2 VALUES (1),(2),(3);
   373  SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
   374  a	t1.a in (select t2.a from t2)
   375  1	true
   376  2	true
   377  3	true
   378  4	false
   379  SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
   380  a	t1.a in (select t2.a from t2,t3 where t3.a=t2.a)
   381  1	true
   382  2	true
   383  3	true
   384  4	false
   385  drop table if exists t1;
   386  drop table if exists t2;
   387  drop table if exists t3;
   388  create table t1 (a int);
   389  insert into t1 values (-1), (-4), (-2), (NULL);
   390  select -10 IN (select a from t1);
   391  -10 IN (select a from t1)
   392  null
   393  DROP TABLE IF EXISTS t1;
   394  create table t1 (a float);
   395  select 10.5 IN (SELECT * from t1 LIMIT 1);
   396  10.5 in (select * from t1 limit 1)
   397  false
   398  select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
   399  SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 46 near " UNION SELECT 1.5);";
   400  select 10.5 IN (SELECT * from t1 UNION SELECT 1.5 LIMIT 1);
   401  10.5 in (select * from t1 union select 1.5 limit 1)
   402  false
   403  DROP TABLE IF EXISTS t1;
   404  create table t1 (a int, b real, c varchar(10));
   405  insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');
   406  select (1, 1, 'a') IN (select a,b,c from t1);
   407  (1, 1, 'a') IN (select a,b,c from t1)
   408  true
   409  select (1, 2, 'a') IN (select a,b,c from t1);
   410  (1, 2, 'a') IN (select a,b,c from t1)
   411  false
   412  select (1, 1, 'a') IN (select b,a,c from t1);
   413  (1, 1, 'a') IN (select b,a,c from t1)
   414  true
   415  select (1, 1, 'a') IN (select a,b,c from t1 where a is not null);
   416  (1, 1, 'a') IN (select a,b,c from t1 where a is not null)
   417  true
   418  select (1, 2, 'a') IN (select a,b,c from t1 where a is not null);
   419  (1, 2, 'a') IN (select a,b,c from t1 where a is not null)
   420  false
   421  select (1, 1, 'a') IN (select b,a,c from t1 where a is not null);
   422  (1, 1, 'a') IN (select b,a,c from t1 where a is not null)
   423  true
   424  select (1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a');
   425  (1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a')
   426  true
   427  select (1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
   428  (1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a')
   429  false
   430  select (1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
   431  (1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a')
   432  true
   433  select (1, 1, 'a') IN (select b,a,c from t1 limit 2);
   434  (1, 1, a) in (select b, a, c from t1 limit 2)
   435  true
   436  DROP TABLE IF EXISTS t1;
   437  create table t1 (a integer, b integer);
   438  select (1,(2,2)) in (select * from t1 );
   439  Operand should contain 2 column(s)
   440  select (1,(2,2)) = (select * from t1 );
   441  Operand should contain 2 column(s)
   442  select (select * from t1) = (1,(2,2));
   443  Operand should contain 1 column(s)
   444  DROP TABLE IF EXISTS t1;
   445  drop table if exists t2;
   446  CREATE TABLE t1 (a1 INT, a2 INT);
   447  CREATE TABLE t2 (b1 INT, b2 INT);
   448  INSERT INTO t1 VALUES (100, 200);
   449  INSERT INTO t1 VALUES (101, 201);
   450  INSERT INTO t2 VALUES (101, 201);
   451  INSERT INTO t2 VALUES (103, 203);
   452  SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1;
   453  ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL
   454  false
   455  false
   456  DROP TABLE IF EXISTS t1;
   457  drop table if exists t2;
   458  CREATE TABLE t1 (
   459  pk INTEGER,
   460  col_int_nokey INTEGER,
   461  col_int_key INTEGER,
   462  col_datetime_key DATETIME,
   463  PRIMARY KEY (pk)
   464  );
   465  INSERT INTO t1 VALUES (1, 1, 7, '2001-11-04 19:07:55.051133');
   466  CREATE TABLE t2(field1 INT, field2 INT);
   467  SELECT * FROM t2 WHERE (field1, field2) IN (
   468  SELECT MAX(col_datetime_key), col_int_key
   469  FROM t1
   470  WHERE col_int_key > col_int_nokey
   471  GROUP BY col_int_key);
   472  field1	field2
   473  DROP TABLE IF EXISTS t1;
   474  drop table if exists t2;
   475  create table t1 (a int, b int);
   476  insert into t1 values (0,0), (2,2), (3,3);
   477  create table t2 (a int, b int);
   478  insert into t2 values (1,1), (3,3);
   479  select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
   480  a	b	Z
   481  0	0	false
   482  2	2	false
   483  3	3	true
   484  insert into t2 values (NULL,4);
   485  select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
   486  a	b	Z
   487  0	0	false
   488  2	2	false
   489  3	3	true
   490  DROP TABLE IF EXISTS t1;
   491  drop table if exists t2;
   492  DROP TABLE IF EXISTS t1;
   493  CREATE TABLE t1 (a INT);
   494  INSERT INTO t1 VALUES (1), (2), (11);
   495  SELECT a, (11, 12) = (SELECT a, 22), (11, 12) IN (SELECT a, 22) FROM t1 GROUP BY t1.a;
   496  a	(11, 12) = (SELECT a, 22)	(11, 12) IN (SELECT a, 22)
   497  1	0	false
   498  2	0	false
   499  11	0	false
   500  SELECT a, (11, 12) = (SELECT a, 12), (11, 12) IN (SELECT a, 12) FROM t1 GROUP BY t1.a;
   501  a	(11, 12) = (SELECT a, 12)	(11, 12) IN (SELECT a, 12)
   502  1	0	false
   503  2	0	false
   504  11	1	true
   505  SELECT a, (11, 12) = (SELECT a, 22), (11, 12) IN (SELECT a, 22) FROM t1;
   506  a	(11, 12) = (SELECT a, 22)	(11, 12) IN (SELECT a, 22)
   507  1	0	false
   508  2	0	false
   509  11	0	false
   510  SELECT a, (11, 12) = (SELECT a, 12), (11, 12) IN (SELECT a, 12) FROM t1;
   511  a	(11, 12) = (SELECT a, 12)	(11, 12) IN (SELECT a, 12)
   512  1	0	false
   513  2	0	false
   514  11	1	true
   515  SELECT a AS x, (11, 12) = (SELECT MAX(x), 22), (11, 12) IN (SELECT MAX(x), 22) FROM t1;
   516  invalid input: column x does not exist
   517  SELECT a AS x, (11, 12) = (SELECT MAX(x), 12), (11, 12) IN (SELECT MAX(x), 12) FROM t1;
   518  invalid input: column x does not exist
   519  DROP TABLE IF EXISTS t1;
   520  SELECT (1,2) = (SELECT NULL, NULL), (1,2) IN (SELECT NULL, NULL);
   521  (1,2) = (SELECT NULL, NULL)	(1,2) IN (SELECT NULL, NULL)
   522  null	null
   523  SELECT (1,2) = (SELECT   1,  NULL), (1,2) IN (SELECT    1, NULL);
   524  (1,2) = (SELECT   1,  NULL)	(1,2) IN (SELECT    1, NULL)
   525  null	null
   526  SELECT (1,2) = (SELECT NULL,    2), (1,2) IN (SELECT NULL,    2);
   527  (1,2) = (SELECT NULL,    2)	(1,2) IN (SELECT NULL,    2)
   528  null	null
   529  SELECT (1,2) = (SELECT NULL,    1), (1,2) IN (SELECT NULL,    1);
   530  (1,2) = (SELECT NULL,    1)	(1,2) IN (SELECT NULL,    1)
   531  false	false
   532  SELECT (1,2) = (SELECT    1,    1), (1,2) IN (SELECT    1,    1);
   533  (1,2) = (SELECT    1,    1)	(1,2) IN (SELECT    1,    1)
   534  false	false
   535  SELECT (1,2) = (SELECT    1,    2), (1,2) IN (SELECT    1,    2);
   536  (1,2) = (SELECT    1,    2)	(1,2) IN (SELECT    1,    2)
   537  true	true
   538  create table t_out (subcase char(3),a1 char(2), b1 char(2), c1 char(2));
   539  create table t_in  (a2 char(2), b2 char(2), c2 char(2));
   540  insert into t_out values ('A.1','2a', NULL, '2a');
   541  insert into t_out values ('A.3', '2a', NULL, '2a');
   542  insert into t_out values ('A.4', '2a', NULL, 'xx');
   543  insert into t_out values ('B.1', '2a', '2a', '2a');
   544  insert into t_out values ('B.2', '2a', '2a', '2a');
   545  insert into t_out values ('B.3', '3a', 'xx', '3a');
   546  insert into t_out values ('B.4', 'xx', '3a', '3a');
   547  insert into t_in values ('1a', '1a', '1a');
   548  insert into t_in values ('2a', '2a', '2a');
   549  insert into t_in values (NULL, '2a', '2a');
   550  insert into t_in values ('3a', NULL, '3a');
   551  select subcase,
   552  (a1, b1, c1)     IN (select * from t_in where a2 = 'no_match') pred_in,
   553  (a1, b1, c1) NOT IN (select * from t_in where a2 = 'no_match') pred_not_in
   554  from t_out where subcase = 'A.1';
   555  subcase	pred_in	pred_not_in
   556  A.1	false	true
   557  select subcase,
   558  (a1, b1, c1)     IN (select * from t_in) pred_in,
   559  (a1, b1, c1) NOT IN (select * from t_in) pred_not_in
   560  from t_out where subcase = 'A.3';
   561  subcase	pred_in	pred_not_in
   562  A.3	null	null
   563  select subcase,
   564  (a1, b1, c1)     IN (select * from t_in) pred_in,
   565  (a1, b1, c1) NOT IN (select * from t_in) pred_not_in
   566  from t_out where subcase = 'A.4';
   567  subcase	pred_in	pred_not_in
   568  A.4	false	true
   569  select subcase,
   570  (a1, b1, c1)     IN (select * from t_in where a2 = 'no_match') pred_in,
   571  (a1, b1, c1) NOT IN (select * from t_in where a2 = 'no_match') pred_not_in
   572  from t_out where subcase = 'B.1';
   573  subcase	pred_in	pred_not_in
   574  B.1	false	true
   575  select subcase,
   576  (a1, b1, c1)     IN (select * from t_in) pred_in,
   577  (a1, b1, c1) NOT IN (select * from t_in) pred_not_in
   578  from t_out where subcase = 'B.2';
   579  subcase	pred_in	pred_not_in
   580  B.2	true	false
   581  select subcase,
   582  (a1, b1, c1)     IN (select * from t_in) pred_in,
   583  (a1, b1, c1) NOT IN (select * from t_in) pred_not_in
   584  from t_out where subcase = 'B.3';
   585  subcase	pred_in	pred_not_in
   586  B.3	null	null
   587  select subcase,
   588  (a1, b1, c1)     IN (select * from t_in) pred_in,
   589  (a1, b1, c1) NOT IN (select * from t_in) pred_not_in
   590  from t_out where subcase = 'B.4';
   591  subcase	pred_in	pred_not_in
   592  B.4	false	true
   593  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   594  where subcase = 'A.1' and
   595  (a1, b1, c1) IN (select * from t_in where a1 = 'no_match');
   596  pred_in
   597  F
   598  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   599  where subcase = 'A.1' and
   600  (a1, b1, c1) NOT IN (select * from t_in where a1 = 'no_match');
   601  pred_not_in
   602  T
   603  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   604  where subcase = 'A.1' and
   605  NOT((a1, b1, c1) IN (select * from t_in where a1 = 'no_match'));
   606  not_pred_in
   607  T
   608  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   609  where subcase = 'A.3' and
   610  (a1, b1, c1) IN (select * from t_in);
   611  pred_in
   612  F
   613  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   614  where subcase = 'A.3' and
   615  (a1, b1, c1) NOT IN (select * from t_in);
   616  pred_not_in
   617  F
   618  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   619  where subcase = 'A.3' and
   620  NOT((a1, b1, c1) IN (select * from t_in));
   621  not_pred_in
   622  F
   623  select case when count(*) > 0 then 'N' else 'wrong result' end as pred_in from t_out
   624  where subcase = 'A.3' and
   625  ((a1, b1, c1) IN (select * from t_in)) is NULL and
   626  ((a1, b1, c1) NOT IN (select * from t_in)) is NULL;
   627  pred_in
   628  N
   629  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   630  where subcase = 'A.4' and
   631  (a1, b1, c1) IN (select * from t_in);
   632  pred_in
   633  F
   634  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   635  where subcase = 'A.4' and
   636  (a1, b1, c1) NOT IN (select * from t_in);
   637  pred_not_in
   638  T
   639  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   640  where subcase = 'A.4' and
   641  NOT((a1, b1, c1) IN (select * from t_in));
   642  not_pred_in
   643  T
   644  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   645  where subcase = 'B.1' and
   646  (a1, b1, c1) IN (select * from t_in where a1 = 'no_match');
   647  pred_in
   648  F
   649  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   650  where subcase = 'B.1' and
   651  (a1, b1, c1) NOT IN (select * from t_in where a1 = 'no_match');
   652  pred_not_in
   653  T
   654  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   655  where subcase = 'B.1' and
   656  NOT((a1, b1, c1) IN (select * from t_in where a1 = 'no_match'));
   657  not_pred_in
   658  T
   659  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   660  where subcase = 'B.2' and
   661  (a1, b1, c1) IN (select * from t_in);
   662  pred_in
   663  T
   664  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   665  where subcase = 'B.2' and
   666  (a1, b1, c1) NOT IN (select * from t_in);
   667  pred_not_in
   668  F
   669  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   670  where subcase = 'B.2' and
   671  NOT((a1, b1, c1) IN (select * from t_in));
   672  not_pred_in
   673  F
   674  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   675  where subcase = 'B.3' and
   676  (a1, b1, c1) IN (select * from t_in);
   677  pred_in
   678  F
   679  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   680  where subcase = 'B.3' and
   681  (a1, b1, c1) NOT IN (select * from t_in);
   682  pred_not_in
   683  F
   684  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   685  where subcase = 'B.3' and
   686  NOT((a1, b1, c1) IN (select * from t_in));
   687  not_pred_in
   688  F
   689  select case when count(*) > 0 then 'N' else 'wrong result' end as pred_in from t_out
   690  where subcase = 'B.3' and
   691  ((a1, b1, c1) IN (select * from t_in)) is NULL and
   692  ((a1, b1, c1) NOT IN (select * from t_in)) is NULL;
   693  pred_in
   694  N
   695  select case when count(*) > 0 then 'T' else 'F' end as pred_in from t_out
   696  where subcase = 'B.4' and
   697  (a1, b1, c1) IN (select * from t_in);
   698  pred_in
   699  F
   700  select case when count(*) > 0 then 'T' else 'F' end as pred_not_in from t_out
   701  where subcase = 'B.4' and
   702  (a1, b1, c1) NOT IN (select * from t_in);
   703  pred_not_in
   704  T
   705  select case when count(*) > 0 then 'T' else 'F' end as not_pred_in from t_out
   706  where subcase = 'B.4' and
   707  NOT((a1, b1, c1) IN (select * from t_in));
   708  not_pred_in
   709  T
   710  DROP TABLE IF EXISTS t_out;
   711  DROP TABLE IF EXISTS t_in;
   712  DROP TABLE IF EXISTS t1;
   713  drop table if exists t2;
   714  create table t1 (a int);
   715  create table t2 (b int);
   716  insert into t1 values (1),(2);
   717  insert into t2 values (1);
   718  select a from t1 where a in (select a from t1 where a in (select b from t2));
   719  a
   720  1
   721  DROP TABLE IF EXISTS t1;
   722  drop table if exists t2;
   723  create table t1 (a int, b int);
   724  create table t2 (a int, b int);
   725  select * from t1 where (a,b) in (select a,b from t2);
   726  a	b
   727  DROP TABLE IF EXISTS t1;
   728  drop table if exists t2;
   729  create table t1 (a int);
   730  insert into t1 values (1), (2), (3);
   731  SELECT 1 FROM t1 WHERE (SELECT 1) in (SELECT 1);
   732  1
   733  1
   734  1
   735  1
   736  DROP TABLE IF EXISTS t1;
   737  DROP TABLE IF EXISTS t1;
   738  drop table if exists t2;
   739  CREATE TABLE t1( a INT );
   740  INSERT INTO t1 VALUES (1),(2);
   741  CREATE TABLE t2( a INT, b INT );
   742  SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
   743  a	b
   744  SELECT * FROM t1 WHERE a IN    ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
   745  a
   746  1
   747  SELECT * FROM t1 WHERE a IN    ( ( SELECT 1 UNION SELECT 1 )  UNION SELECT 1 );
   748  a
   749  1
   750  SELECT * FROM t1 WHERE a IN    ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
   751  a
   752  1
   753  DROP TABLE IF EXISTS t1;
   754  drop table if exists t2;
   755  drop table if exists t3;
   756  drop table if exists t4;
   757  drop table if exists t5;
   758  create table t0 (a int);
   759  insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
   760  create table t1 (
   761  a int(11) default null,
   762  b int(11) default null
   763  );
   764  insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C;
   765  create table t2 (a int(11) default null);
   766  insert into t2 values (0),(1);
   767  create table t3 (a int(11) default null);
   768  insert into t3 values (0),(1);
   769  create table t4 (a int(11) default null);
   770  insert into t4 values (0),(1);
   771  create table t5 (a int(11) default null);
   772  insert into t5 values (0),(1),(0),(1);
   773  select * from t2, t3
   774  where
   775  t2.a < 10 and
   776  t3.a+1 = 2 and
   777  t3.a in (select t1.b from t1
   778  where t1.a+1=t1.a+1 and
   779  t1.a < (select t4.a+10
   780  from t4, t5 limit 2));
   781  internal error: scalar subquery returns more than 1 row
   782  DROP TABLE IF EXISTS t1;
   783  drop table if exists t2;
   784  drop table if exists t3;
   785  drop table if exists t4;
   786  drop table if exists t5;
   787  CREATE TABLE t1 (i1 int DEFAULT NULL,i2 int DEFAULT NULL) ;
   788  INSERT INTO t1 VALUES (1,    NULL);
   789  INSERT INTO t1 VALUES (2,    3);
   790  INSERT INTO t1 VALUES (4,    NULL);
   791  INSERT INTO t1 VALUES (4,    0);
   792  INSERT INTO t1 VALUES (NULL, NULL);
   793  CREATE TABLE t2 (i1 int DEFAULT NULL,i2 int DEFAULT NULL) ;
   794  INSERT INTO t2 VALUES (4, NULL);
   795  INSERT INTO t2 VALUES (5, 0);
   796  SELECT i1, i2
   797  FROM t1
   798  WHERE (i1, i2)
   799  NOT IN (SELECT i1, i2 FROM t2);
   800  i1	i2
   801  1	null
   802  2	3
   803  INSERT INTO t1 VALUES (NULL, NULL);
   804  SELECT i1, i2
   805  FROM t1
   806  WHERE (i1, i2)
   807  NOT IN (SELECT i1, i2 FROM t2);
   808  i1	i2
   809  1	null
   810  2	3
   811  drop table if exists t1;
   812  drop table if exists t2;
   813  CREATE TABLE t1 (a INT);
   814  INSERT INTO t1 VALUES(1);
   815  CREATE TABLE t2(a INT);
   816  INSERT INTO t2 VALUES(1),(1),(1),(1),(1);
   817  SELECT
   818  (
   819  (SELECT 1 IN (SELECT 1 FROM t1 AS x1))
   820  IN
   821  (
   822  SELECT 1 FROM t2
   823  WHERE a IN (SELECT 4 FROM t1 AS x2)
   824  )
   825  ) AS result
   826  FROM t1 AS x3;
   827  result
   828  false
   829  SELECT
   830  (
   831  (36, (SELECT 1 IN (SELECT 1 FROM t1 AS x1)))
   832  IN
   833  (
   834  SELECT 36, 1 FROM t2
   835  WHERE a IN (SELECT 4 FROM t1 AS x2)
   836  )
   837  ) AS result
   838  FROM t1 AS x3;
   839  result
   840  false
   841  DROP TABLE IF EXISTS t1;
   842  drop table if exists t2;
   843  CREATE TABLE t1 (
   844  id int(11) default NULL
   845  ) ;
   846  INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3);
   847  CREATE TABLE t2 (
   848  id int(11) default NULL,
   849  name varchar(15) default NULL
   850  ) ;
   851  INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita');
   852  update t2 set t2.name='lenka' where t2.id in (select id from t1);
   853  select * from t2;
   854  id	name
   855  4	vita
   856  1	lenka
   857  2	lenka
   858  1	lenka
   859  delete from t1 where t1.id in  (select id from t2);
   860  select * from t1;
   861  id
   862  3
   863  DROP TABLE IF EXISTS t1;
   864  drop table if exists t2;
   865  DROP TABLE IF EXISTS t1;
   866  drop table if exists t2;
   867  DROP TABLE IF EXISTS t3;
   868  CREATE TABLE t1 (a int(11) NOT NULL default 0, PRIMARY KEY  (a));
   869  CREATE TABLE t2 (a int(11) default 0);
   870  CREATE TABLE t3 (a int(11) default 0);
   871  INSERT INTO t3 VALUES (1),(2),(3);
   872  INSERT INTO t1 VALUES (1),(2),(3),(4);
   873  INSERT INTO t2 VALUES (1),(2),(3);
   874  SELECT t1.a FROM t1 where t1.a in (select t2.a from t2 order by t2.a desc) ;
   875  a
   876  1
   877  2
   878  3
   879  DROP TABLE IF EXISTS t1;
   880  drop table if exists t2;
   881  CREATE TABLE `t1` ( `aid` int(11) NOT NULL default 0, `bid` int(11) NOT NULL default 0);
   882  CREATE TABLE `t2` ( `aid` int(11) NOT NULL default 0, `bid` int(11) NOT NULL default 0);
   883  insert into t1 values (1,1),(1,2),(2,1),(2,2);
   884  insert into t2 values (1,2),(2,2);
   885  select * from t1 where t1.aid not in (select aid from t2 where bid=t1.bid);
   886  aid	bid
   887  1	1
   888  2	1
   889  select * from t1 where t1.aid in (select aid from t2 where bid=t1.bid);
   890  aid	bid
   891  1	2
   892  2	2
   893  DROP TABLE IF EXISTS t1;
   894  drop table if exists t2;
   895  CREATE TABLE t1(select_id BIGINT, values_id BIGINT);
   896  INSERT INTO t1 VALUES (1, 1);
   897  CREATE TABLE t2 (select_id BIGINT, values_id BIGINT);
   898  INSERT INTO t2 VALUES (0, 1), (0, 2), (0, 3), (1, 5);
   899  SELECT values_id FROM t1
   900  WHERE values_id IN (SELECT values_id FROM t2  WHERE select_id IN (1, 0));
   901  values_id
   902  1
   903  SELECT values_id FROM t1 WHERE values_id IN (SELECT values_id FROM t2 WHERE select_id BETWEEN 0 AND 1);
   904  values_id
   905  1
   906  SELECT values_id FROM t1 WHERE values_id IN (SELECT values_id FROM t2 WHERE select_id = 0 OR select_id = 1);
   907  values_id
   908  1
   909  DROP TABLE IF EXISTS t1;
   910  drop table if exists t2;
   911  CREATE TABLE t1 (a INT NOT NULL);
   912  INSERT INTO t1 VALUES (1),(-1), (65),(66);
   913  CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY);
   914  INSERT INTO t2 VALUES (65),(66);
   915  SELECT a FROM t1 WHERE a NOT IN (65,66);
   916  a
   917  1
   918  -1
   919  SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
   920  a
   921  1
   922  -1
   923  DROP TABLE IF EXISTS t1;
   924  drop table if exists t2;
   925  CREATE TABLE t1 (a INT);
   926  INSERT INTO t1 VALUES(1);
   927  CREATE TABLE t2 (placeholder CHAR(11));
   928  INSERT INTO t2 VALUES("placeholder");
   929  SELECT (1, 2) IN (SELECT t1.a, 2)         FROM t1 GROUP BY t1.a;
   930  (1, 2) IN (SELECT t1.a, 2)
   931  true
   932  SELECT (1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a;
   933  (1, 2) IN (SELECT t1.a, 2 FROM t2)
   934  true
   935  DROP TABLE IF EXISTS t1;
   936  drop table if exists t2;
   937  CREATE TABLE t1 (a INT);
   938  INSERT INTO t1 VALUES (1),(2),(3);
   939  CREATE TABLE t2 (a INT);
   940  INSERT INTO t1 VALUES (1),(2),(3);
   941  SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE false);
   942  1
   943  1
   944  1
   945  1
   946  1
   947  1
   948  1
   949  DROP TABLE IF EXISTS t1;
   950  drop table if exists t2;
   951  DROP TABLE IF EXISTS t1;
   952  drop table if exists t2;
   953  drop table if exists t3;
   954  CREATE TABLE t1 (a int, b int);
   955  CREATE TABLE t2 (c int, d int);
   956  CREATE TABLE t3 (e int);
   957  INSERT INTO t1 VALUES
   958  (1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
   959  INSERT INTO t2 VALUES
   960  (2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
   961  INSERT INTO t3 VALUES (10), (30), (10), (20) ;
   962  SELECT a FROM t1 GROUP BY a HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20);
   963  SQL syntax error: aggregate function max not allowed in WHERE clause
   964  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2 WHERE MAX(b)<d);
   965  SQL syntax error: aggregate function max not allowed in WHERE clause
   966  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>d);
   967  SQL syntax error: aggregate function max not allowed in WHERE clause
   968  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2  WHERE d >= SOME(SELECT e FROM t3 WHERE MAX(b)=e));
   969  SQL syntax error: aggregate function max not allowed in WHERE clause
   970  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2  WHERE  EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
   971  SQL syntax error: aggregate function max not allowed in WHERE clause
   972  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2  WHERE d > SOME(SELECT e FROM t3 WHERE MAX(b)=e));
   973  SQL syntax error: aggregate function max not allowed in WHERE clause
   974  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2  WHERE  EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e < d));
   975  SQL syntax error: aggregate function max not allowed in WHERE clause
   976  SELECT a FROM t1 GROUP BY a  HAVING a IN (SELECT c FROM t2  WHERE MIN(b) < d AND EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
   977  SQL syntax error: aggregate function min not allowed in WHERE clause
   978  DROP TABLE IF EXISTS t1;
   979  drop table if exists t2;
   980  drop table if exists t3;
   981  create table t1 (a int, b int);
   982  insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
   983  create table t2 (a int, b int);
   984  insert into t2 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
   985  update t2 set b=1;
   986  create table t3 (a int, oref int);
   987  insert into t3 values (1, 1), (NULL,1), (NULL,0);
   988  select a, oref,t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z from t3;
   989  a	oref	Z
   990  1	1	true
   991  null	1	null
   992  null	0	false
   993  DROP TABLE IF EXISTS t1;
   994  drop table if exists t2;
   995  drop table if exists t3;
   996  create table t1 (a int NOT NULL, b int NOT NULL);
   997  insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
   998  create table t2 (a int, b int);
   999  insert into t2 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
  1000  update t2 set b=1;
  1001  create table t3 (a int, oref int);
  1002  insert into t3 values (1, 1), (NULL,1), (NULL,0);
  1003  select a, oref,t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z from t3;
  1004  a	oref	Z
  1005  1	1	true
  1006  null	1	null
  1007  null	0	false
  1008  DROP TABLE IF EXISTS t1;
  1009  drop table if exists t2;
  1010  drop table if exists t3;
  1011  create table t1 (oref int, grp int);
  1012  insert into t1 (oref, grp) values(1, 1),(1, 1);
  1013  create table t2 (oref int, a int);
  1014  insert into t2 values(1, NULL),(2, NULL);
  1015  select a, oref, a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2;
  1016  SQL syntax error: column "t2.oref" must appear in the GROUP BY clause or be used in an aggregate function
  1017  DROP TABLE IF EXISTS t1;
  1018  drop table if exists t2;
  1019  create table t1 (a int, b int, primary key (a));
  1020  insert into t1 values (1,1), (3,1),(100,1);
  1021  create table t2 (a int, b int);
  1022  insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0);
  1023  select a,b, a in (select a from t1 where t1.b = t2.b union select a from t1 where t1.b = t2.b) Z from t2 ;
  1024  a	b	z
  1025  1	1	true
  1026  2	1	false
  1027  null	1	null
  1028  null	0	false
  1029  select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ;
  1030  a	b	Z
  1031  1	1	true
  1032  2	1	false
  1033  null	1	null
  1034  null	0	false
  1035  DROP TABLE IF EXISTS t1;
  1036  drop table if exists t2;
  1037  drop table if exists t3;
  1038  drop table if exists t4;
  1039  create table t3 (a int);
  1040  insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
  1041  create table t2 (a int, b int, oref int);
  1042  insert into t2 values (NULL,1, 100), (NULL,2, 100);
  1043  create table t1 (a int, b int, c int);
  1044  insert into t1 select 2*A, 2*A, 100 from t3;
  1045  create table t4 (x int);
  1046  insert into t4 select A.a + 10*B.a from t1 A, t1 B;
  1047  select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) z from t2;
  1048  a	b	oref	z
  1049  null	1	100	false
  1050  null	2	100	null
  1051  DROP TABLE IF EXISTS t1;
  1052  drop table if exists t2;
  1053  drop table if exists t3;
  1054  drop table if exists t4;
  1055  create table t1 (oref char(4), grp int, ie1 int, ie2 int);
  1056  insert into t1 (oref, grp, ie1, ie2) values('aa', 10, 2, 1),('aa', 10, 1, 1),('aa', 20, 2, 1),('bb', 10, 3, 1),('cc', 10, 4, 2),('cc', 20, 3, 2),('ee', 10, 2, 1),('ee', 10, 1, 2),('ff', 20, 2, 2),('ff', 20, 1, 2);
  1057  create table t2 (oref char(4), a int, b int);
  1058  insert into t2 values('ee', NULL, 1),('bb', 2, 1),('ff', 2, 2),('cc', 3, NULL),('bb', NULL, NULL),('aa', 1, 1),('dd', 1, NULL);
  1059  select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=3 and b is null ;
  1060  oref	a	b	Z
  1061  cc	3	null	null
  1062  insert into t2 values ('new1', 10,10);
  1063  insert into t1 values ('new1', 1234, 10, NULL);
  1064  select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10;
  1065  oref	a	b	Z
  1066  new1	10	10	null
  1067  DROP TABLE IF EXISTS t1;
  1068  drop table if exists t2;
  1069  create table t1 (oref char(4), grp int, ie int);
  1070  insert into t1 (oref, grp, ie) values ('aa', 10, 2),('aa', 10, 1),('aa', 20, NULL),('bb', 10, 3),('cc', 10, 4),('cc', 20, NULL),('ee', 10, NULL),('ee', 10, NULL),('ff', 20, 2),('ff', 20, 1);
  1071  create table t2 (oref char(4), a int);
  1072  insert into t2 values('ee', NULL),('bb', 2),('ff', 2),('cc', 3),('aa', 1),('dd', NULL),('bb', NULL);
  1073  select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
  1074  oref	a	Z
  1075  ee	null	null
  1076  bb	2	false
  1077  ff	2	true
  1078  cc	3	null
  1079  aa	1	true
  1080  dd	null	false
  1081  bb	null	null
  1082  select oref, a from t2 where a in (select ie from t1 where oref=t2.oref);
  1083  oref	a
  1084  ff	2
  1085  aa	1
  1086  select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref);
  1087  oref	a
  1088  bb	2
  1089  dd	null
  1090  select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
  1091  oref	a	Z
  1092  ee	null	null
  1093  bb	2	false
  1094  ff	2	false
  1095  cc	3	null
  1096  aa	1	true
  1097  dd	null	false
  1098  bb	null	null
  1099  select oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref group by grp);
  1100  oref	a
  1101  aa	1
  1102  select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref group by grp);
  1103  oref	a
  1104  bb	2
  1105  ff	2
  1106  dd	null
  1107  update t1 set ie=3 where oref='ff' and ie=1;
  1108  select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
  1109  oref	a	Z
  1110  ee	null	null
  1111  bb	2	false
  1112  ff	2	true
  1113  cc	3	null
  1114  aa	1	true
  1115  dd	null	false
  1116  bb	null	null
  1117  select oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref group by grp);
  1118  oref	a
  1119  ff	2
  1120  aa	1
  1121  select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref group by grp);
  1122  oref	a
  1123  bb	2
  1124  dd	null
  1125  select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1) Z from t2;
  1126  oref	a	Z
  1127  ee	null	false
  1128  bb	2	false
  1129  ff	2	true
  1130  cc	3	false
  1131  aa	1	false
  1132  dd	null	false
  1133  bb	null	null
  1134  select oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1);
  1135  oref	a
  1136  ff	2
  1137  select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1);
  1138  oref	a
  1139  ee	null
  1140  bb	2
  1141  cc	3
  1142  aa	1
  1143  dd	null
  1144  DROP TABLE IF EXISTS t1;
  1145  drop table if exists t2;
  1146  create table t1 (oref char(4), grp int, ie1 int, ie2 int);
  1147  insert into t1 (oref, grp, ie1, ie2) values ('aa', 10, 2, 1),('aa', 10, 1, 1),('aa', 20, 2, 1),('bb', 10, 3, 1),('cc', 10, 4, 2),('cc', 20, 3, 2),('ee', 10, 2, 1),('ee', 10, 1, 2),('ff', 20, 2, 2),('ff', 20, 1, 2);
  1148  create table t2 (oref char(4), a int, b int);
  1149  insert into t2 values('ee', NULL, 1),('bb', 2, 1), ('ff', 2, 2),('cc', 3, NULL),('bb', NULL, NULL),('aa', 1, 1),('dd', 1, NULL);
  1150  select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2;
  1151  oref	a	b	Z
  1152  ee	null	1	null
  1153  bb	2	1	false
  1154  ff	2	2	true
  1155  cc	3	null	null
  1156  bb	null	null	null
  1157  aa	1	1	true
  1158  dd	1	null	false
  1159  select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref);
  1160  oref	a	b
  1161  ff	2	2
  1162  aa	1	1
  1163  select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref);
  1164  oref	a	b
  1165  bb	2	1
  1166  dd	1	null
  1167  select oref, a, b,(a,b) in (select min(ie1),max(ie2) from t1 where oref=t2.oref group by grp) Z from t2;
  1168  oref	a	b	Z
  1169  ee	null	1	false
  1170  bb	2	1	false
  1171  ff	2	2	false
  1172  cc	3	null	null
  1173  bb	null	null	null
  1174  aa	1	1	true
  1175  dd	1	null	false
  1176  select oref, a, b from t2 where (a,b) in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp);
  1177  oref	a	b
  1178  aa	1	1
  1179  select oref, a, b from t2 where (a,b) not in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp);
  1180  oref	a	b
  1181  ee	null	1
  1182  bb	2	1
  1183  ff	2	2
  1184  dd	1	null
  1185  DROP TABLE IF EXISTS t1;
  1186  drop table if exists t2;
  1187  create table t1 (oref char(4), grp int, ie int primary key);
  1188  insert into t1 (oref, grp, ie) values('aa', 10, 2),('aa', 10, 1),('bb', 10, 3),('cc', 10, 4),('cc', 20, 5),('cc', 10, 6);
  1189  create table t2 (oref char(4), a int);
  1190  insert into t2 values  ('ee', NULL),('bb', 2),('cc', 5),('cc', 2),('cc', NULL),('aa', 1),('bb', NULL);
  1191  select oref, a, a in (select ie from t1 where oref=t2.oref) z from t2;
  1192  oref	a	z
  1193  ee	null	false
  1194  bb	2	false
  1195  cc	5	true
  1196  cc	2	false
  1197  cc	null	null
  1198  aa	1	true
  1199  bb	null	null
  1200  select oref, a from t2 where a in (select ie from t1 where oref=t2.oref);
  1201  oref	a
  1202  cc	5
  1203  aa	1
  1204  select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref);
  1205  oref	a
  1206  ee	null
  1207  bb	2
  1208  cc	2
  1209  select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) z from t2;
  1210  oref	a	z
  1211  ee	null	false
  1212  bb	2	false
  1213  cc	5	true
  1214  cc	2	false
  1215  cc	null	null
  1216  aa	1	true
  1217  bb	null	null
  1218  DROP TABLE IF EXISTS t1;
  1219  drop table if exists t2;
  1220  CREATE TABLE t1 (a int);
  1221  CREATE TABLE t2 (b int, PRIMARY KEY(b));
  1222  INSERT INTO t1 VALUES (1), (NULL), (4);
  1223  INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6);
  1224  SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
  1225  a
  1226  SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
  1227  a
  1228  1
  1229  4
  1230  DROP TABLE IF EXISTS t1;
  1231  drop table if exists t2;
  1232  CREATE TABLE t1 (id int);
  1233  CREATE TABLE t2 (id int PRIMARY KEY);
  1234  CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10));
  1235  INSERT INTO t1 VALUES (2), (NULL), (3), (1);
  1236  INSERT INTO t2 VALUES (234), (345), (457);
  1237  INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa');
  1238  SELECT * FROM t1 WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3  WHERE t3.name='xxx' AND t2.id=t3.id);
  1239  id
  1240  2
  1241  null
  1242  3
  1243  1
  1244  SELECT (t1.id IN (SELECT t2.id FROM t2,t3  WHERE t3.name='xxx' AND t2.id=t3.id)) AS x FROM t1;
  1245  x
  1246  false
  1247  false
  1248  false
  1249  false
  1250  DROP TABLE IF EXISTS t1;
  1251  drop table if exists t2;
  1252  drop table if exists t3;
  1253  CREATE TABLE t1 (
  1254  pk INT PRIMARY KEY,
  1255  int_key INT,
  1256  varchar_key VARCHAR(5) UNIQUE,
  1257  varchar_nokey VARCHAR(5)
  1258  );
  1259  INSERT INTO t1 VALUES (9, 7,NULL,NULL), (10,8,'p' ,'p');
  1260  SELECT varchar_nokey FROM t1
  1261  WHERE NULL NOT IN (
  1262  SELECT INNR.pk FROM t1 AS INNR2
  1263  LEFT JOIN t1 AS INNR ON ( INNR2.int_key = INNR.int_key )
  1264  WHERE INNR.varchar_key > 'n{'
  1265  );
  1266  varchar_nokey
  1267  DROP TABLE IF EXISTS t1;
  1268  drop table if exists t1;
  1269  drop table if exists t2;
  1270  CREATE TABLE t1(i INT);
  1271  INSERT INTO t1 VALUES (1), (2), (3);
  1272  CREATE TABLE t1s(i INT);
  1273  INSERT INTO t1s VALUES (10), (20), (30);
  1274  CREATE TABLE t2s(i INT);
  1275  INSERT INTO t2s VALUES (100), (200), (300);
  1276  SELECT * FROM t1
  1277  WHERE t1.i NOT IN
  1278  (
  1279  SELECT t2s.i
  1280  FROM
  1281  t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
  1282  HAVING t2s.i = 999
  1283  );
  1284  SQL syntax error: column "t2s.i" must appear in the GROUP BY clause or be used in an aggregate function
  1285  SELECT * FROM t1
  1286  WHERE t1.I IN
  1287  (
  1288  SELECT t2s.i
  1289  FROM
  1290  t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
  1291  HAVING t2s.i = 999
  1292  );
  1293  SQL syntax error: column "t2s.i" must appear in the GROUP BY clause or be used in an aggregate function
  1294  SELECT * FROM t1
  1295  WHERE NOT t1.I = ANY
  1296  (
  1297  SELECT t2s.i
  1298  FROM
  1299  t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
  1300  HAVING t2s.i = 999
  1301  );
  1302  SQL syntax error: column "t2s.i" must appear in the GROUP BY clause or be used in an aggregate function
  1303  SELECT * FROM t1
  1304  WHERE t1.i = ANY (
  1305  SELECT t2s.i
  1306  FROM
  1307  t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
  1308  HAVING t2s.i = 999
  1309  );
  1310  SQL syntax error: column "t2s.i" must appear in the GROUP BY clause or be used in an aggregate function
  1311  DROP TABLE IF EXISTS t1;
  1312  drop table if exists t2;
  1313  drop table if exists t3;
  1314  CREATE TABLE parent (id int);
  1315  INSERT INTO parent VALUES (1), (2);
  1316  CREATE TABLE child (parent_id int, other int);
  1317  INSERT INTO child VALUES (1,NULL);
  1318  SELECT    p.id, c.parent_id
  1319  FROM      parent p
  1320  LEFT JOIN child  c
  1321  ON        p.id = c.parent_id
  1322  WHERE     c.parent_id NOT IN (
  1323  SELECT parent_id
  1324  FROM   child
  1325  WHERE  parent_id = 3
  1326  );
  1327  id	parent_id
  1328  1	1
  1329  2	null
  1330  SELECT    p.id, c.parent_id
  1331  FROM      parent p
  1332  LEFT JOIN child  c
  1333  ON        p.id = c.parent_id
  1334  WHERE     c.parent_id IN (
  1335  SELECT parent_id
  1336  FROM   child
  1337  WHERE  parent_id = 3
  1338  );
  1339  id	parent_id
  1340  SELECT    p.id, c.parent_id
  1341  FROM      parent p
  1342  LEFT JOIN child  c
  1343  ON        p.id = c.parent_id
  1344  WHERE     c.parent_id IN (
  1345  SELECT parent_id
  1346  FROM   child
  1347  WHERE  parent_id = 3
  1348  );
  1349  id	parent_id
  1350  DROP TABLE IF EXISTS parent;
  1351  DROP TABLE IF EXISTS child;
  1352  DROP TABLE IF EXISTS cc;
  1353  DROP TABLE IF EXISTS bb;
  1354  DROP TABLE IF EXISTS c;
  1355  DROP TABLE IF EXISTS b;
  1356  CREATE TABLE cc (
  1357  pk INT,
  1358  col_int_key INT,
  1359  col_varchar_key VARCHAR(1),
  1360  PRIMARY KEY (pk)
  1361  );
  1362  INSERT INTO cc VALUES (10,7,'v');
  1363  INSERT INTO cc VALUES (11,1,'r');
  1364  CREATE TABLE bb (
  1365  pk INT,
  1366  col_date_key DATE,
  1367  PRIMARY KEY (pk)
  1368  );
  1369  INSERT INTO bb VALUES (10,'2002-02-21');
  1370  CREATE TABLE c (
  1371  pk INT,
  1372  col_int_key INT,
  1373  col_varchar_key VARCHAR(1),
  1374  PRIMARY KEY (pk)
  1375  );
  1376  INSERT INTO c VALUES (1,NULL,'w');
  1377  INSERT INTO c VALUES (19,NULL,'f');
  1378  CREATE TABLE b (
  1379  pk INT,
  1380  col_int_key INT,
  1381  col_varchar_key VARCHAR(1),
  1382  PRIMARY KEY (pk)
  1383  );
  1384  INSERT INTO b VALUES (1,7,'f');
  1385  SELECT col_int_key
  1386  FROM b granparent1
  1387  WHERE (col_int_key, col_int_key) IN (
  1388  SELECT parent1.pk, parent1.pk
  1389  FROM bb parent1 JOIN cc parent2
  1390  ON parent2.col_varchar_key = parent2.col_varchar_key
  1391  WHERE granparent1.col_varchar_key IN (
  1392  SELECT col_varchar_key
  1393  FROM c)
  1394  AND parent1.pk = granparent1.col_int_key
  1395  ORDER BY parent1.col_date_key
  1396  );
  1397  col_int_key
  1398  DROP TABLE IF EXISTS  t1;
  1399  DROP TABLE IF EXISTS t2;
  1400  DROP TABLE IF EXISTS t1xt2;
  1401  CREATE TABLE t1 (
  1402  id_1 int(5) NOT NULL,
  1403  t varchar(4) DEFAULT NULL
  1404  );
  1405  CREATE TABLE t2 (
  1406  id_2 int(5) NOT NULL,
  1407  t varchar(4) DEFAULT NULL
  1408  );
  1409  CREATE TABLE t1xt2 (
  1410  id_1 int(5) NOT NULL,
  1411  id_2 int(5) NOT NULL
  1412  );
  1413  INSERT INTO t1 VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd');
  1414  INSERT INTO t2 VALUES (2, 'bb'), (3, 'cc'), (4, 'dd'), (12, 'aa');
  1415  INSERT INTO t1xt2 VALUES (2, 2), (3, 3), (4, 4);
  1416  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1417  id_1
  1418  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN ((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1)));
  1419  id_1
  1420  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1))));
  1421  id_1
  1422  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1423  id_1
  1424  1
  1425  2
  1426  3
  1427  4
  1428  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN ((SELECT t1xt2.id_2 FROM t1xt2 where t1.id_1 = t1xt2.id_1)));
  1429  id_1
  1430  1
  1431  2
  1432  3
  1433  4
  1434  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (((SELECT t1xt2.id_2 FROM t1xt2 where t1.id_1 = t1xt2.id_1))));
  1435  id_1
  1436  1
  1437  2
  1438  3
  1439  4
  1440  insert INTO t1xt2 VALUES (1, 12);
  1441  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1442  id_1
  1443  1
  1444  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN ((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1)));
  1445  id_1
  1446  1
  1447  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1))));
  1448  id_1
  1449  1
  1450  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1451  id_1
  1452  2
  1453  3
  1454  4
  1455  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN ((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1)));
  1456  id_1
  1457  2
  1458  3
  1459  4
  1460  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1))));
  1461  id_1
  1462  2
  1463  3
  1464  4
  1465  insert INTO t1xt2 VALUES (2, 12);
  1466  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1467  id_1
  1468  1
  1469  2
  1470  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN ((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1)));
  1471  id_1
  1472  1
  1473  2
  1474  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 IN (((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1))));
  1475  id_1
  1476  1
  1477  2
  1478  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1));
  1479  id_1
  1480  3
  1481  4
  1482  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN ((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1)));
  1483  id_1
  1484  3
  1485  4
  1486  SELECT DISTINCT t1.id_1 FROM t1 WHERE(12 NOT IN (((SELECT t1xt2.id_2 FROM t1xt2 WHERE t1.id_1 = t1xt2.id_1))));
  1487  id_1
  1488  3
  1489  4
  1490  DROP TABLE IF EXISTS t1;
  1491  DROP TABLE IF EXISTS t2;
  1492  DROP TABLE IF EXISTS t1xt2;
  1493  DROP TABLE IF EXISTS t1;
  1494  CREATE TABLE t1(a int );
  1495  INSERT INTO t1 VALUES(0);
  1496  SELECT NULL IN (SELECT 1 FROM t1);
  1497  NULL IN (SELECT 1 FROM t1)
  1498  null
  1499  SELECT (NULL AND 1) IN (SELECT 1 FROM t1);
  1500  (null and 1) in (select 1 from t1)
  1501  null
  1502  SELECT (NULL, 1) IN (SELECT 1,1 FROM t1);
  1503  (NULL, 1) IN (SELECT 1,1 FROM t1)
  1504  null
  1505  SELECT (NULL, NULL) IN (SELECT 1,1 FROM t1);
  1506  (NULL, NULL) IN (SELECT 1,1 FROM t1)
  1507  null
  1508  SELECT (NULL OR 1) IN (SELECT 1 FROM t1);
  1509  (null or 1) in (select 1 from t1)
  1510  true
  1511  SELECT (NULL IS NULL) IN  (SELECT 1 FROM t1);
  1512  (null is null) in (select 1 from t1)
  1513  true
  1514  DELETE FROM t1;
  1515  SELECT NULL IN (SELECT 1 FROM t1);
  1516  NULL IN (SELECT 1 FROM t1)
  1517  false
  1518  SELECT (NULL AND 1) IN (SELECT 1 FROM t1);
  1519  (null and 1) in (select 1 from t1)
  1520  false
  1521  SELECT (NULL, 1) IN (SELECT 1,1 FROM t1);
  1522  (NULL, 1) IN (SELECT 1,1 FROM t1)
  1523  false
  1524  SELECT (NULL, NULL) IN (SELECT 1,1 FROM t1);
  1525  (NULL, NULL) IN (SELECT 1,1 FROM t1)
  1526  false
  1527  SELECT (NULL OR 1) IN (SELECT 1 FROM t1);
  1528  (null or 1) in (select 1 from t1)
  1529  false
  1530  SELECT (NULL IS NULL) IN  (SELECT 1 FROM t1);
  1531  (null is null) in (select 1 from t1)
  1532  false
  1533  DROP TABLE IF EXISTS t1;
  1534  CREATE TABLE t1 (a INTEGER);
  1535  INSERT INTO t1 VALUES (1), (2), (3);
  1536  SELECT 2 IN ( SELECT 5 UNION SELECT NULL ) FROM t1;
  1537  'union' will be supported in future version.
  1538  DROP TABLE IF EXISTS t1;