表A:ID=1
表B:ID=2
表C:ID=3
表D要求是使用多表查询 把表A里ID=1的值,表B里ID=2的值和表C里ID=3的值查出 并存储到表D里。
当时面试的时候一紧张...连join都不会了。
希望各位大侠给一个比较优化的答案......
表B:ID=2
表C:ID=3
表D要求是使用多表查询 把表A里ID=1的值,表B里ID=2的值和表C里ID=3的值查出 并存储到表D里。
当时面试的时候一紧张...连join都不会了。
希望各位大侠给一个比较优化的答案......
调试欢乐多
select id from a where id=1
union all
select id from b where id=2
union all
select id from c where id=3
insert into d(id)
select id from a where id=1
union all
select id from b where id=2
union all
select id from c where id=3
from 表A ainner join 表B b
on a.id = b.idinner join 表C c
on b.id = c.id
select id from a where id=1
union all
select id from b where id=2
union all
select id from c where id=3
insert into d(id)
select id from a where id=1
union all
select id from b where id=2
union all
select id from c where id=3