home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / mysql-test / t / user_var.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  825 b   |  20 lines  |  [TEXT/ttxt]

  1. error 1204;
  2. set @a := foo;
  3. set @a := connection_id() + 3;
  4. select @a - connection_id();
  5.  
  6. # Check using and setting variables with SELECT DISTINCT
  7.  
  8. drop table if exists t1,t2;
  9. CREATE TABLE t1 ( i int not null, v int not null,index (i));
  10. insert into t1 values (1,1),(1,3),(2,1); 
  11. create table t2 (i int not null, unique (i));
  12. insert into t2 select distinct i from t1;
  13. select * from t2; 
  14. select distinct t2.i,@vv1:=if(sv1.i,1,0),@vv2:=if(sv2.i,1,0),@vv3:=if(sv3.i,1,0), @vv1+@vv2+@vv3 from t2 left join t1 as sv1 on sv1.i=t2.i and sv1.v=1 left join t1 as sv2 on sv2.i=t2.i and sv2.v=2 left join t1 as sv3 on sv3.i=t2.i and sv3.v=3;
  15. explain select * from t1 where i=@vv1;
  16. explain select * from t1 where @vv1:=@vv1+1 and i=@vv1;
  17. explain select @vv1:=i from t1 where i=@vv1;
  18. explain select * from t1 where i=@vv1;
  19. drop table t1,t2;
  20.