~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/subselect.result

  • Committer: Brian Aker
  • Date: 2009-08-04 06:21:17 UTC
  • mfrom: (1108.2.2 merge)
  • Revision ID: brian@gaz-20090804062117-fef8x6y3ydzrvab3
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
614
614
0       10
615
615
1       11
616
616
drop table t1, t2;
617
 
#multi-delete with subselects
618
 
create table t11 (a int NOT NULL, b int, primary key (a));
619
 
create table t12 (a int NOT NULL, b int, primary key (a));
620
 
create temporary table t2 (a int NOT NULL, b int, primary key (a)) ENGINE=MyISAM;
621
 
insert into t11 values (0, 10),(1, 11),(2, 12);
622
 
insert into t12 values (33, 10),(22, 11),(2, 12);
623
 
insert into t2 values (1, 21),(2, 12),(3, 23);
624
 
select * from t11;
625
 
a       b
626
 
0       10
627
 
1       11
628
 
2       12
629
 
select * from t12;
630
 
a       b
631
 
2       12
632
 
22      11
633
 
33      10
634
 
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
635
 
ERROR HY000: You can't specify target table 't12' for update in FROM clause
636
 
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
637
 
ERROR 21000: Subquery returns more than 1 row
638
 
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
639
 
select * from t11;
640
 
a       b
641
 
0       10
642
 
1       11
643
 
select * from t12;
644
 
a       b
645
 
22      11
646
 
33      10
647
 
drop table t11, t12, t2;
648
617
#insert with subselects
649
618
CREATE TABLE t1 (x int);
650
619
create table t2 (a int);
1160
1129
3
1161
1130
drop table t1;
1162
1131
#
1163
 
# Multi update test
1164
 
#
1165
 
CREATE TABLE t1 (
1166
 
id int default NULL
1167
 
);
1168
 
INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3);
1169
 
CREATE TEMPORARY TABLE t2 (
1170
 
id int default NULL,
1171
 
name varchar(15) default NULL
1172
 
) ENGINE=MyISAM;
1173
 
INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita');
1174
 
update t1, t2 set t2.name='lenka' where t2.id in (select id from t1);
1175
 
select * from t2;
1176
 
id      name
1177
 
4       vita
1178
 
1       lenka
1179
 
2       lenka
1180
 
1       lenka
1181
 
drop table t1,t2;
1182
 
#
1183
1132
# correct NULL in <CONSTANT> IN (SELECT ...)
1184
1133
#
1185
1134
create temporary table t1 (a int, unique index indexa (a)) ENGINE=MyISAM;