日期:2014-05-18  浏览次数:20569 次

MSSQL过滤及其他问题
INSERT   INTO   table2
            (film_id,   brief)
SELECT   film_id,   brief   AS   Expr1
FROM   table1
WHERE   (name   =   '越狱II18 ')

+============================+

上面语句解决了越狱II18的film_id和brief从table1导入到table2

1.如果我要防止下次重复提交越狱II18这组信息,如何实现语句过滤

2.还有table2本身还有个字段是type(table1没有此字段),想通过这个语句直接传入type值为abcd

谢谢!

------解决方案--------------------
INSERT INTO table2
(type,film_id, brief)
SELECT 'abcd ',film_id, brief AS Expr1
FROM table1
WHERE (name = '越狱II18 ') and film_id not in (select distinct film_id from table2)