【发布时间】:2014-02-12 13:44:10
【问题描述】:
set @tabela='cliente';
set @campo='codigo';
set @t1 = concat('SELECT count(0) FROM information_schema.COLUMNS WHERE
information_schema.COLUMNS.TABLE_NAME =',@tabela,' AND
information_schema.COLUMNS.COLUMN_NAME =',@campo);
PREPARE teste FROM @t1;
execute teste;
================================================ ================
[SQL] set @tabela='cliente'; Affected rows: 0 Time: 0.003ms
[SQL] set @campo='codigo'; Affected rows: 0 Time: 0.001ms
[SQL]
set @t1 = concat('SELECT count(0) FROM information_schema.COLUMNS WHERE information_schema.COLUMNS.TABLE_NAME =',@tabela,' AND information_schema.COLUMNS.COLUMN_NAME =',@campo);
Affected rows: 0
Time: 0.001ms
[SQL] PREPARE teste FROM @t1; [Err] 1054 - 'where 子句'中的未知列 'cliente'
*为什么? *
【问题讨论】: