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 / variables.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  1.5 KB  |  41 lines  |  [TEXT/ttxt]

  1. #
  2. # test variables
  3. #
  4. drop table if exists t1;
  5. set @`test`=1,@TEST=3,@select=2,@t5=1.23456;
  6. select @test,@`select`,@TEST,@not_used;
  7. set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
  8. select @test_int,@test_double,@test_string,@test_string2,@select;
  9. set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
  10. select @test_int,@test_double,@test_string,@test_string2;
  11. set @test_int="hellohello",@test_double="hellohello",@test_string="hellohello",@test_string2="hellohello";
  12. select @test_int,@test_double,@test_string,@test_string2;
  13. set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
  14. select @test_int,@test_double,@test_string,@test_string2;
  15. select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  16. select @t5;
  17.  
  18. #
  19. # Test problem with WHERE and variables
  20. #
  21.  
  22. CREATE TABLE t1 (c_id INT(4) NOT NULL, c_name CHAR(20), c_country CHAR(3), PRIMARY KEY(c_id));
  23. INSERT INTO t1 VALUES (1,'Bozo','USA'),(2,'Ronald','USA'),(3,'Kinko','IRE'),(4,'Mr. Floppy','GB');
  24. SELECT @min_cid:=min(c_id), @max_cid:=max(c_id) from t1;
  25. SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid;
  26. SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid OR c_id=666;
  27. ALTER TABLE t1 DROP PRIMARY KEY;
  28. select * from t1 where c_id=@min_cid OR c_id=@max_cid;
  29. drop table t1;
  30.  
  31. #
  32. # Test system variables
  33. #
  34.  
  35. select @@VERSION=version();
  36. select last_insert_id(345);
  37. select @@IDENTITY,last_insert_id();
  38. select @@identity;
  39. --error 1193
  40. select @@unknown_variable;
  41.