--disable_warnings drop table if exists t_aux, t2 ; --enable_warnings # auxiliary statement create table t_aux ( a int ) ; insert into t_aux values(1) ; select a from t_aux; # correct working sequence 1 # two statements, select with column and table create table t2 ( a int ) ; insert into t2 select a from t_aux; select a from t2; drop table t2 ; # correct working sequence 2 # two statements, select with constant and table create table t2 ( a int ) ; insert into t2 select 1 from t_aux; select a from t2; drop table t2 ; # correct working sequence 3 # two statements, select with constant and without table create table t2 ( a int ) ; insert into t2 select 1 ; select a from t2; drop table t2 ; ### now the CREATE TABLE ... SELECTs # correct working statement 1 # one statement, select with column and table create table t2 ( a int ) select a from t_aux ; select a from t2; drop table t2 ; # wrong working statement 2 # one statement, select with constant and table create table t2 ( a int ) select 1 from t_aux; select a from t2; drop table t2 ; # wrong working statement 3 # one statement, select with constant and without table create table t2 ( a int ) select 1 ; select a from t2; drop table t2 ; # wrong working statement 4 create table t2 ( a int ) select CAST(1 AS signed INTEGER) from t_aux; select a from t2; drop table t2 ; # wrong working statement 5 create table t2 ( a int, b int ) select a, 1 from t_aux; select a,b from t2; drop table t2 ; select 1, a from t_aux; # wrong working statement 6 create table t2 ( a int, b int ) select 1, a from t_aux; select a,b from t2; drop table t2 ; # the reason/solution ? # this statement works correct create table t2 ( a int ) select 1 as a ; select a from t2; drop table t2 ; drop table t_aux ;