github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/subquery/subquery-with-exists.result (about)

     1  SELECT EXISTS(SELECT 1+1);
     2  EXISTS(SELECT 1+1)
     3  true
     4  drop table if exists t1;
     5  drop table if exists t2;
     6  drop table if exists t3;
     7  drop table if exists t4;
     8  drop table if exists t5;
     9  drop table if exists t6;
    10  drop table if exists t7;
    11  create table t1 (a int);
    12  create table t2 (a int, b int);
    13  create table t3 (a int);
    14  create table t4 (a int not null, b int not null);
    15  insert into t1 values (2);
    16  insert into t2 values (1,7),(2,7);
    17  insert into t4 values (4,8),(3,8),(5,9);
    18  insert into t3 values (6),(7),(3);
    19  select * from t3 where exists (select * from t2 where t2.b=t3.a);
    20  a
    21  7
    22  select * from t3 where not exists (select * from t2 where t2.b=t3.a);
    23  a
    24  6
    25  3
    26  insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
    27  insert into t2 values (2,10);
    28  create table t5 (a int);
    29  insert into t5 values (5);
    30  insert into t5 values (2);
    31  create table t6 (patient_uq int, clinic_uq int);
    32  create table t7( uq int primary key, name char(25));
    33  insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
    34  insert into t6 values (1,1),(1,2),(2,2),(1,3);
    35  select * from t6 where exists (select * from t7 where uq = clinic_uq);
    36  patient_uq	clinic_uq
    37  1	1
    38  1	2
    39  2	2
    40  drop table if exists t1;
    41  drop table if exists t2;
    42  drop table if exists t3;
    43  drop table if exists t4;
    44  drop table if exists t5;
    45  drop table if exists t6;
    46  drop table if exists t7;
    47  CREATE TABLE `t1` (
    48  `numeropost` int(8) unsigned NOT NULL,
    49  `maxnumrep` int(10) unsigned NOT NULL default 0,
    50  PRIMARY KEY  (`numeropost`)
    51  );
    52  INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
    53  CREATE TABLE `t2` (
    54  `mot` varchar(30) NOT NULL default '',
    55  `topic` int(8) unsigned NOT NULL default 0,
    56  `dt` date,
    57  `pseudo` varchar(35) NOT NULL default ''
    58  );
    59  INSERT INTO t2 (mot,topic,dt,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
    60  SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND dt >= date'2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
    61  numeropost	maxnumrep
    62  43506	2
    63  40143	1
    64  drop table if exists t1;
    65  drop table if exists t2;
    66  drop table if exists t3;
    67  CREATE TABLE `t1` (
    68  `mot` varchar(30) NOT NULL default '',
    69  `topic` int(8) unsigned NOT NULL default 0,
    70  `dt` date ,
    71  `pseudo` varchar(35) NOT NULL default ''
    72  );
    73  CREATE TABLE `t2` (
    74  `mot` varchar(30) NOT NULL default '',
    75  `topic` int(8) unsigned NOT NULL default 0,
    76  `dt` date,
    77  `pseudo` varchar(35) NOT NULL default ''
    78  ) ;
    79  CREATE TABLE `t3` (
    80  `numeropost` int(8) unsigned NOT NULL,
    81  `maxnumrep` int(10) unsigned NOT NULL default 0,
    82  PRIMARY KEY  (`numeropost`)
    83  );
    84  INSERT INTO t1 VALUES ('joce','1',null,'joce'),('test','2',null,'test');
    85  INSERT INTO t2 VALUES ('joce','1',null,'joce'),('test','2',null,'test');
    86  INSERT INTO t3 VALUES (1,1);
    87  SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE numeropost=topic);
    88  topic
    89  2
    90  DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE numeropost=topic));
    91  select * from t1;
    92  mot	topic	dt	pseudo
    93  joce	1	null	joce
    94  drop table if exists t1;
    95  drop table if exists t2;
    96  drop table if exists t3;
    97  create table t1 (a int, b int);
    98  insert into t1 values (1,2),(3,4);
    99  select * from t1 up where exists (select * from t1 where t1.a=up.a);
   100  a	b
   101  1	2
   102  3	4
   103  drop table if exists t1;
   104  drop table if exists t2;
   105  drop table if exists t3;
   106  CREATE TABLE t1 (a INT, b INT);
   107  INSERT INTO t1 VALUES (1,1),(2,2);
   108  CREATE TABLE t2 (a INT, b INT);
   109  INSERT INTO t2 VALUES (1,1),(2,2);
   110  CREATE TABLE t3 (a INT, b INT);
   111  SELECT COUNT(*) FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) ORDER BY COUNT(*);
   112  COUNT(*)
   113  2
   114  SELECT COUNT(*) FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) ORDER BY COUNT(*);
   115  COUNT(*)
   116  2
   117  drop table if exists t1;
   118  drop table if exists t2;
   119  drop table if exists t3;
   120  CREATE TABLE t1 (f1 varchar(1));
   121  INSERT INTO t1 VALUES ('v'),('s');
   122  CREATE TABLE t2 (f1_key varchar(1));
   123  INSERT INTO t2 VALUES ('j'),('v'),('c'),('m'),('d'),('d'),('y'),('t'),('d'),('s');
   124  SELECT table1.f1, table2.f1_key FROM t1 AS table1, t2 AS table2
   125  WHERE EXISTS
   126  (
   127  SELECT DISTINCT f1_key
   128  FROM t2
   129  WHERE f1_key != table2.f1_key AND f1_key >= table1.f1 );
   130  f1	f1_key
   131  s	j
   132  v	j
   133  s	v
   134  v	v
   135  s	c
   136  v	c
   137  s	m
   138  v	m
   139  s	d
   140  v	d
   141  s	d
   142  v	d
   143  s	y
   144  v	y
   145  s	t
   146  v	t
   147  s	d
   148  v	d
   149  s	s
   150  v	s
   151  drop table if exists t1;
   152  drop table if exists t2;
   153  drop table if exists t3;
   154  CREATE TABLE t1( pk int PRIMARY KEY,uk int,ukn int NOT NULL,ik int,d int);
   155  INSERT INTO t1 VALUES (0, NULL, 0, NULL, NULL),(1, 10, 20, 30, 40),(2, 20, 40, 60, 80);
   156  CREATE TABLE t2(pk int PRIMARY KEY);
   157  INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9),(10),
   158  (11),(12),(13),(14),(15),(16),(17),(18),(19),(20),
   159  (21),(22),(23),(24),(25),(26),(27),(28),(29),(30),
   160  (31),(32),(33),(34),(35),(36),(37),(38),(39),(40),
   161  (41),(42),(43),(44),(45),(46),(47),(48),(49),(50),
   162  (51),(52),(53),(54),(55),(56),(57),(58),(59),(60),
   163  (61),(62),(63),(64),(65),(66),(67),(68),(69),(70),
   164  (71),(72),(73),(74),(75),(76),(77),(78),(79),(80);
   165  SELECT 1  WHERE EXISTS (SELECT * FROM t1 AS it);
   166  1
   167  1
   168  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT 1);
   169  pk	uk	ukn	ik	d
   170  0	null	0	null	null
   171  1	10	20	30	40
   172  2	20	40	60	80
   173  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT 1 WHERE FALSE);
   174  pk	uk	ukn	ik	d
   175  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it);
   176  pk	uk	ukn	ik	d
   177  0	null	0	null	null
   178  1	10	20	30	40
   179  2	20	40	60	80
   180  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = 1);
   181  pk	uk	ukn	ik	d
   182  0	null	0	null	null
   183  1	10	20	30	40
   184  2	20	40	60	80
   185  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = 1);
   186  pk	uk	ukn	ik	d
   187  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = 1);
   188  pk	uk	ukn	ik	d
   189  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = 1);
   190  pk	uk	ukn	ik	d
   191  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk);
   192  pk	uk	ukn	ik	d
   193  0	null	0	null	null
   194  1	10	20	30	40
   195  2	20	40	60	80
   196  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.uk);
   197  pk	uk	ukn	ik	d
   198  1	10	20	30	40
   199  2	20	40	60	80
   200  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.ukn);
   201  pk	uk	ukn	ik	d
   202  0	null	0	null	null
   203  1	10	20	30	40
   204  2	20	40	60	80
   205  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.d);
   206  pk	uk	ukn	ik	d
   207  1	10	20	30	40
   208  2	20	40	60	80
   209  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk > ot.pk);
   210  pk	uk	ukn	ik	d
   211  0	null	0	null	null
   212  1	10	20	30	40
   213  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk > ot.uk);
   214  pk	uk	ukn	ik	d
   215  1	10	20	30	40
   216  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn > ot.ukn);
   217  pk	uk	ukn	ik	d
   218  0	null	0	null	null
   219  1	10	20	30	40
   220  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik > ot.ik);
   221  pk	uk	ukn	ik	d
   222  1	10	20	30	40
   223  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d > ot.d);
   224  pk	uk	ukn	ik	d
   225  1	10	20	30	40
   226  SELECT * FROM t2 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk);
   227  pk
   228  1
   229  2
   230  SELECT * FROM t2 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.pk);
   231  pk
   232  10
   233  20
   234  SELECT * FROM t2 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.pk);
   235  pk
   236  20
   237  40
   238  SELECT * FROM t2 AS ot WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.pk);
   239  pk
   240  40
   241  80
   242  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t2 AS it WHERE ot.d = it.pk - 1);
   243  pk	uk	ukn	ik	d
   244  1	10	20	30	40
   245  SELECT * FROM t1 AS ot WHERE EXISTS (SELECT * FROM t1 AS it1 JOIN t2 AS it2 ON it1.pk > it2.pk WHERE ot.d = it2.pk);
   246  pk	uk	ukn	ik	d
   247  drop table if exists t1;
   248  drop table if exists t2;
   249  drop table if exists t3;
   250  CREATE TABLE t1 (a int);
   251  SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE 127 = 55);
   252  a
   253  drop table if exists t1;
   254  drop table if exists t2;
   255  drop table if exists t3;
   256  create table t1 (s1 int);
   257  create table t2 (s1 int);
   258  insert into t1 values (1);
   259  insert into t2 values (1);
   260  select * from t1 where exists (select s1 from t2 group by s1 having max(t2.s1)=t1.s1);
   261  SQL syntax error: column "t1.s1" must appear in the GROUP BY clause or be used in an aggregate function
   262  drop table if exists t1;
   263  drop table if exists t2;
   264  create table t1 (id int not null, text varchar(20) not null default '', primary key (id));
   265  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');
   266  select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
   267  SQL syntax error: column "t1.id" must appear in the GROUP BY clause or be used in an aggregate function
   268  drop table if exists t1;
   269  drop table if exists t2;
   270  drop table if exists t3;
   271  CREATE TABLE t1 (a int, b int);
   272  CREATE TABLE t2 (c int, d int);
   273  CREATE TABLE t3 (e int);
   274  INSERT INTO t1 VALUES(1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
   275  INSERT INTO t2 VALUES(2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
   276  INSERT INTO t3 VALUES (10), (30), (10), (20) ;
   277  SELECT a FROM t1 GROUP BY a
   278  HAVING a IN (SELECT c FROM t2
   279  WHERE  EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
   280  a
   281  2
   282  3
   283  SELECT a FROM t1 GROUP BY a
   284  HAVING a IN (SELECT c FROM t2
   285  WHERE  EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e < d));
   286  a
   287  2
   288  SELECT a FROM t1 GROUP BY a
   289  HAVING a IN (SELECT c FROM t2
   290  WHERE MIN(b) < d AND
   291  EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
   292  a
   293  2
   294  SELECT a FROM t1
   295  WHERE EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) = c) GROUP BY a;
   296  a
   297  3
   298  4
   299  SELECT a FROM t1 GROUP BY a
   300  HAVING EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) = c);
   301  SQL syntax error: column "a" must appear in the GROUP BY clause or be used in an aggregate function
   302  SELECT a FROM t1
   303  WHERE a < 3 AND
   304  EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) != c) GROUP BY a;
   305  a
   306  1
   307  2
   308  SELECT a FROM t1
   309  WHERE a < 3 AND
   310  EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) != c);
   311  a
   312  1
   313  2
   314  1
   315  2
   316  2
   317  SELECT t1.a FROM t1 GROUP BY t1.a
   318  HAVING t1.a < ALL(SELECT t2.c FROM t2 GROUP BY t2.c
   319  HAVING EXISTS(SELECT t3.e FROM t3 GROUP BY t3.e
   320  HAVING SUM(t1.a+t2.c) < t3.e/4));
   321  a
   322  1
   323  2
   324  SELECT t1.a FROM t1 GROUP BY t1.a
   325  HAVING t1.a > ALL(SELECT t2.c FROM t2
   326  WHERE EXISTS(SELECT t3.e FROM t3 GROUP BY t3.e
   327  HAVING SUM(t1.a+t2.c) < t3.e/4));
   328  a
   329  4
   330  SELECT t1.a FROM t1 GROUP BY t1.a
   331  HAVING t1.a > ALL(SELECT t2.c FROM t2
   332  WHERE EXISTS(SELECT t3.e FROM t3
   333  WHERE SUM(t1.a+t2.c) < t3.e/4));
   334  Invalid use of group function
   335  drop table if exists t1;
   336  drop table if exists t2;
   337  drop table if exists t3;
   338  CREATE TABLE t1 (id int NOT NULL, st CHAR(2));
   339  INSERT INTO t1 VALUES (3,'FL'), (2,'GA'), (4,'FL'), (1,'GA'), (5,'NY'), (7,'FL'), (6,'NY');
   340  CREATE TABLE t2 (id int NOT NULL);
   341  INSERT INTO t2 VALUES (7), (5), (1), (3);
   342  SELECT id, st FROM t1  WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
   343  id	st
   344  1	GA
   345  3	FL
   346  7	FL
   347  SELECT id, st FROM t1  WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) GROUP BY id;
   348  SQL syntax error: column "t1.st" must appear in the GROUP BY clause or be used in an aggregate function
   349  SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
   350  id	st
   351  2	GA
   352  4	FL
   353  SELECT id, st FROM t1 WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) GROUP BY id;
   354  SQL syntax error: column "t1.st" must appear in the GROUP BY clause or be used in an aggregate function
   355  drop table if exists t1;
   356  drop table if exists t2;
   357  drop table if exists t3;
   358  CREATE TABLE t1 (a INT, b INT);
   359  INSERT INTO t1 VALUES (1, 2), (1,3), (1,4), (2,1), (2,2);
   360  SELECT a1.a, COUNT(*) FROM t1 a1 WHERE a1.a = 1 AND EXISTS( SELECT a2.a FROM t1 a2 WHERE a2.a = a1.a) GROUP BY a1.a;
   361  a	COUNT(*)
   362  1	3
   363  DROP TABLE if exists t1;
   364  drop table if exists t1;
   365  drop table if exists t2;
   366  CREATE TABLE t1 ( a int, b int );
   367  INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
   368  SELECT EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a > t1.a) IS NULL from t1 a;
   369  EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a > t1.a) IS NULL
   370  false
   371  false
   372  false
   373  SELECT EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a < t1.a) IS NOT NULL from t1 a;
   374  EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a < t1.a) IS NOT NULL
   375  true
   376  true
   377  true
   378  SELECT EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a = t1.a) IS NULL from t1 a;
   379  EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a = t1.a) IS NULL
   380  false
   381  false
   382  false
   383  drop table if exists t1;
   384  drop table if exists t1;
   385  create table t1 (df decimal(5,1));
   386  insert into t1 values(1.1);
   387  select 1.1 * exists(select * from t1);
   388  invalid argument operator *, bad value [DECIMAL64 BOOL]
   389  drop table if exists t1;
   390  drop table if exists t1;
   391  CREATE TABLE t1 (i INT);
   392  SELECT * FROM t1 WHERE NOT EXISTS
   393  (
   394  (SELECT i FROM t1) UNION
   395  (SELECT i FROM t1)
   396  );
   397  i
   398  SELECT * FROM t1 WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
   399  i
   400  drop table if exists t1;
   401  drop table if exists t2;
   402  drop table if exists t3;
   403  CREATE TABLE t1 (id char(4) PRIMARY KEY, c int);
   404  CREATE TABLE t2 (c int);
   405  INSERT INTO t1 VALUES ('aa', 1);
   406  INSERT INTO t2 VALUES (1);
   407  SELECT * FROM t1
   408  WHERE EXISTS (SELECT c FROM t2 WHERE c=1
   409  UNION
   410  SELECT c from t2 WHERE c=t1.c);
   411  'union' will be supported in future version.
   412  INSERT INTO t1 VALUES ('bb', 2), ('cc', 3), ('dd',1);
   413  SELECT * FROM t1
   414  WHERE EXISTS (SELECT c FROM t2 WHERE c=1
   415  UNION
   416  SELECT c from t2 WHERE c=t1.c);
   417  'union' will be supported in future version.
   418  INSERT INTO t2 VALUES (2);
   419  CREATE TABLE t3 (c int);
   420  INSERT INTO t3 VALUES (1);
   421  SELECT * FROM t1
   422  WHERE EXISTS (SELECT t2.c FROM t2 JOIN t3 ON t2.c=t3.c WHERE t2.c=1
   423  UNION
   424  SELECT c from t2 WHERE c=t1.c);
   425  'union' will be supported in future version.
   426  drop table if exists t1;
   427  drop table if exists t2;
   428  drop table if exists t3;
   429  CREATE TABLE t1 (a INT);
   430  CREATE TABLE t2 (a INT);
   431  INSERT INTO t1 VALUES (1),(2);
   432  INSERT INTO t2 VALUES (1),(2);
   433  SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
   434  2
   435  2
   436  2
   437  SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a));
   438  2
   439  2
   440  2
   441  drop table if exists t1;
   442  drop table if exists t2;
   443  drop table if exists t1;
   444  drop table if exists t2;
   445  drop table if exists t3;
   446  CREATE TABLE t1 ( c1 int );
   447  INSERT INTO t1 VALUES ( 1 );
   448  INSERT INTO t1 VALUES ( 2 );
   449  INSERT INTO t1 VALUES ( 3 );
   450  INSERT INTO t1 VALUES ( 6 );
   451  CREATE TABLE t2 ( c2 int );
   452  INSERT INTO t2 VALUES ( 1 );
   453  INSERT INTO t2 VALUES ( 4 );
   454  INSERT INTO t2 VALUES ( 5 );
   455  INSERT INTO t2 VALUES ( 6 );
   456  CREATE TABLE t3 ( c3 int );
   457  INSERT INTO t3 VALUES ( 7 );
   458  INSERT INTO t3 VALUES ( 8 );
   459  SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
   460  WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL );
   461  c1	c2
   462  2	null
   463  3	null
   464  drop table if exists t1;
   465  drop table if exists t2;
   466  drop table if exists t3;
   467  CREATE TABLE t1 (a int);
   468  INSERT INTO t1 VALUES
   469  (1), (2), (3), (4), (5), (6), (7), (8), (9),(10);
   470  SELECT * FROM t1
   471  WHERE EXISTS (SELECT * FROM t1) AND
   472  EXISTS (SELECT * FROM t1) AND
   473  EXISTS (SELECT * FROM t1) AND
   474  EXISTS (SELECT * FROM t1) AND
   475  EXISTS (SELECT * FROM t1) AND
   476  EXISTS (SELECT * FROM t1) AND
   477  EXISTS (SELECT * FROM t1) AND
   478  EXISTS (SELECT * FROM t1) AND
   479  EXISTS (SELECT * FROM t1) AND
   480  EXISTS (SELECT * FROM t1) AND
   481  EXISTS (SELECT * FROM t1) AND
   482  EXISTS (SELECT * FROM t1) AND
   483  EXISTS (SELECT * FROM t1) AND
   484  EXISTS (SELECT * FROM t1) AND
   485  EXISTS (SELECT * FROM t1) AND
   486  EXISTS (SELECT * FROM t1) AND
   487  EXISTS (SELECT * FROM t1) AND
   488  EXISTS (SELECT * FROM t1) AND
   489  EXISTS (SELECT * FROM t1) AND
   490  EXISTS (SELECT * FROM t1) AND
   491  EXISTS (SELECT * FROM t1) AND
   492  EXISTS (SELECT * FROM t1) AND
   493  EXISTS (SELECT * FROM t1) AND
   494  EXISTS (SELECT * FROM t1) AND
   495  EXISTS (SELECT * FROM t1) AND
   496  EXISTS (SELECT * FROM t1) AND
   497  EXISTS (SELECT * FROM t1) AND
   498  EXISTS (SELECT * FROM t1) AND
   499  EXISTS (SELECT * FROM t1) AND
   500  EXISTS (SELECT * FROM t1);
   501  a
   502  1
   503  2
   504  3
   505  4
   506  5
   507  6
   508  7
   509  8
   510  9
   511  10
   512  drop table if exists t1;
   513  drop table if exists t2;
   514  CREATE TABLE t1(pk INT PRIMARY KEY, a INT);
   515  INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20);
   516  CREATE TABLE t2(pk INT PRIMARY KEY, a INT, b INT);
   517  INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100);
   518  SELECT * FROM t1  WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b);
   519  SQL syntax error: for SELECT DISTINCT, ORDER BY expressions must appear in select list
   520  drop table if exists t1;
   521  drop table if exists t2;