数据库中有两个表,一个是resource,另一个是resinterview,他们都有字段email,我想将email相同的resinterview中的resinterviewId导入到resource表中的InterviewId字段中。注意,email有相同的也有不同的,需要将email相同的数据查出来。请问各位高手怎么写sql语句?
------解决方案--------------------
- SQL code
INSERT INTO resource (interviewId)VALUES (SELECT resinterviewId FROM resinterview WHERE email IN (SELECT email FROM resinterview GROUP BY email HAVING Count(email) >= 2))
------解决方案--------------------
- SQL code
--resource表select t.[email] from(select [email],count(*) cnt from [resource]group by [email]) twhere t.[cnt]>1------------------------resinterview表select t.[email] from(select [email],count(*) cnt from [resinterview]group by [email]) twhere t.[cnt]>1