mysql信息\u架构列插入到其他表中并进行修改

mysql信息\u架构列插入到其他表中并进行修改,mysql,sql,Mysql,Sql,我有以下选择: SELECT col.table_name, col.column_name, col.ordinal_position, col.is_nullable, col.data_type from information_schema.COLUMNS col where col.table_schema = 'i2cwac' and col.column_name not in ('id','modifiedAt','modifiedBy',

我有以下选择:

SELECT 
    col.table_name, col.column_name, col.ordinal_position, col.is_nullable, col.data_type
from 
    information_schema.COLUMNS col 
where 
    col.table_schema = 'i2cwac' and
    col.column_name not in ('id','modifiedAt','modifiedBy','createdAt','createdBy') and
    col.table_name = 'users'
;
我想把所有这些都插入一个名为“table”的表中(我有这个表,所有列都由select返回),它有一个名为“enabled”(位(1))的新列,我还想更改它在“is_nullable”列中插入的内容

上面的select在“is_nullable”列中返回“YES”或“NO”,但在“enabled”列中的表“table”中,我需要1或0

我该怎么做

您可以使用将是/否映射到1/0

insert into table (columns_names_here)
select    
   col.table_name, .... 
   case when col.is_nullable = 'YES' then 1 else 0 end as enabled, 
   col.data_type
from 
 ....
您可以使用将是/否映射到1/0

insert into table (columns_names_here)
select    
   col.table_name, .... 
   case when col.is_nullable = 'YES' then 1 else 0 end as enabled, 
   col.data_type
from 
 ....