两个表ta和tb
将tb中的数据插入ta中,
insert into ta (name, sex, age, xx)
select name, sex,age ,(xx的值)
from tb
where
tb.name = ...
关于xx的值,根据tb表中的字段yy来确定,如果yy为空,xx为1, 如果yy飞空, xx为2
xx的值那一块代码应该怎么写,多谢
两个表ta和tb
将tb中的数据插入ta中,
insert into ta (name, sex, age, xx)
select name, sex,age ,(xx的值)
from tb
where
tb.name = ...
关于xx的值,根据tb表中的字段yy来确定,如果yy为空,xx为1, 如果yy飞空, xx为2
xx的值那一块代码应该怎么写,多谢
insert into ta (name, sex, age, xx)
select name, sex,age ,case when tb.yy is null then 1 else 2 end
from tb
where
tb.name = ...