📄 ps_7ndb.result
字号:
1 one3 three2 twoprepare stmt1 from ' select a,b from t1order by ? ';execute stmt1 using @arg00;a b4 four1 one3 three2 twoset @arg00=1 ;execute stmt1 using @arg00;a b1 one2 two3 three4 fourset @arg00=0 ;execute stmt1 using @arg00;ERROR 42S22: Unknown column '?' in 'order clause'set @arg00=1;prepare stmt1 from ' select a,b from t1 order by alimit 1 ';execute stmt1 ;a b1 oneprepare stmt1 from ' select a,b from t1 order by a limit ? ';execute stmt1 using @arg00;a b1 oneset @arg00='b' ;set @arg01=0 ;set @arg02=2 ;set @arg03=2 ;select sum(a), @arg00 from t1 where a > @arg01and b is not null group by substr(b,@arg02)having sum(a) <> @arg03 ;sum(a) @arg003 b1 b4 bprepare stmt1 from ' select sum(a), ? from t1 where a > ?and b is not null group by substr(b,?)having sum(a) <> ? ';execute stmt1 using @arg00, @arg01, @arg02, @arg03;sum(a) ?3 b1 b4 btest_sequence------ join tests ------select first.a as a1, second.a as a2 from t1 first, t1 secondwhere first.a = second.a order by a1 ;a1 a21 12 23 34 4prepare stmt1 from ' select first.a as a1, second.a as a2 from t1 first, t1 second where first.a = second.a order by a1 ';execute stmt1 ;a1 a21 12 23 34 4set @arg00='ABC';set @arg01='two';set @arg02='one';select first.a, @arg00, second.a FROM t1 first, t1 secondwhere @arg01 = first.b or first.a = second.a or second.b = @arg02order by second.a, first.a;a @arg00 a1 ABC 12 ABC 13 ABC 14 ABC 12 ABC 22 ABC 33 ABC 32 ABC 44 ABC 4prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second where ? = first.b or first.a = second.a or second.b = ? order by second.a, first.a';execute stmt1 using @arg00, @arg01, @arg02;a ? a1 ABC 12 ABC 13 ABC 14 ABC 12 ABC 22 ABC 33 ABC 32 ABC 44 ABC 4drop table if exists t2 ;create table t2 as select * from t1 ;set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;the join statement is:SELECT * FROM t2 right join t1 using(a) order by t2.a prepare stmt1 from @query9 ;execute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourthe join statement is:SELECT * FROM t2 natural right join t1 order by t2.a prepare stmt1 from @query8 ;execute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourthe join statement is:SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a prepare stmt1 from @query7 ;execute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourthe join statement is:SELECT * FROM t2 left join t1 using(a) order by t2.a prepare stmt1 from @query6 ;execute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourthe join statement is:SELECT * FROM t2 natural left join t1 order by t2.a prepare stmt1 from @query5 ;execute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourthe join statement is:SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a prepare stmt1 from @query4 ;execute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourthe join statement is:SELECT * FROM t2 join t1 using(a) order by t2.a prepare stmt1 from @query3 ;execute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourexecute stmt1 ;a b b1 one one2 two two3 three three4 four fourthe join statement is:SELECT * FROM t2 natural join t1 order by t2.a prepare stmt1 from @query2 ;execute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourexecute stmt1 ;a b1 one2 two3 three4 fourthe join statement is:SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a prepare stmt1 from @query1 ;execute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourexecute stmt1 ;a b a b1 one 1 one2 two 2 two3 three 3 three4 four 4 fourdrop table t2 ;test_sequence------ subquery tests ------prepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where b = ''two'') ';execute stmt1 ;a b2 twoset @arg00='two' ;select a, b FROM t1 outer_table wherea = (select a from t1 where b = 'two' ) and b=@arg00 ;a b2 twoprepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where b = ''two'') and b=? ';execute stmt1 using @arg00;a b2 twoset @arg00='two' ;select a, b FROM t1 outer_table wherea = (select a from t1 where b = @arg00 ) and b='two' ;a b2 twoprepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where b = ? ) and b=''two'' ' ;execute stmt1 using @arg00;a b2 twoset @arg00=3 ;set @arg01='three' ;select a,b FROM t1 where (a,b) in (select 3, 'three');a b3 threeselect a FROM t1 where (a,b) in (select @arg00,@arg01);a3prepare stmt1 from ' select a FROM t1 where (a,b) in (select ?, ?) ';execute stmt1 using @arg00, @arg01;a3set @arg00=1 ;set @arg01='two' ;set @arg02=2 ;set @arg03='two' ;select a, @arg00, b FROM t1 outer_table whereb=@arg01 and a = (select @arg02 from t1 where b = @arg03 ) ;a @arg00 b2 1 twoprepare stmt1 from ' select a, ?, b FROM t1 outer_table where b=? and a = (select ? from t1 where b = ? ) ' ;execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;a ? b2 1 twoprepare stmt1 from 'select c4 FROM t9 where c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;execute stmt1 using @arg01, @arg02;c4prepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where b = outer_table.b ) order by a ';execute stmt1 ;a b1 one2 two3 three4 fourprepare stmt1 from ' SELECT a as ccc from t1 where a+1= (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';execute stmt1 ;ccc1deallocate prepare stmt1 ;prepare stmt1 from ' SELECT a as ccc from t1 where a+1= (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';execute stmt1 ;ccc1deallocate prepare stmt1 ;prepare stmt1 from ' SELECT a as ccc from t1 where a+1= (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';execute stmt1 ;ccc1deallocate prepare stmt1 ;set @arg00='two' ;select a, b FROM t1 outer_table wherea = (select a from t1 where b = outer_table.b ) and b=@arg00 ;a b2 twoprepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where b = outer_table.b) and b=? ';execute stmt1 using @arg00;a b2 twoset @arg00=2 ;select a, b FROM t1 outer_table wherea = (select a from t1 where a = @arg00 and b = outer_table.b) and b='two' ;a b2 twoprepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where a = ? and b = outer_table.b) and b=''two'' ' ;execute stmt1 using @arg00;a b2 twoset @arg00=2 ;select a, b FROM t1 outer_table wherea = (select a from t1 where outer_table.a = @arg00 and a=2) and b='two' ;a b2 twoprepare stmt1 from ' select a, b FROM t1 outer_table where a = (select a from t1 where outer_table.a = ? and a=2) and b=''two'' ' ;execute stmt1 using @arg00;a b2 twoset @arg00=1 ;set @arg01='two' ;set @arg02=2 ;set @arg03='two' ;select a, @arg00, b FROM t1 outer_table whereb=@arg01 and a = (select @arg02 from t1 where outer_table.b = @arg03and outer_table.a=a ) ;a @arg00 b2 1 two
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -