当前位置: 代码迷 >> Sql Server >> 数据库有关问题,请解答!
  详细解决方案

数据库有关问题,请解答!

热度:40   发布时间:2016-04-27 11:08:12.0
数据库问题,请各位高手解答!急!!!
数据库中有两个表,一个是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
  相关解决方案