2
Insert into tbproppayh (id_payment)
SELECT s.id_payment FROM session.set_values s
WHERE EXISTS id_payment;

2013 年 7 月 18 日星期四 10:21:42 执行。. .

    E_US09C5 line 1, Syntax error on 'id_payment'.  The correct syntax is:
        SELECT [ALL|DISTINCT] target_list
          FROM table(s)
          [WHERE search_cond]
          [GROUP BY col(s)]
          [HAVING search_cond]
     [UNION subselect]
     [ORDER BY col(s)]
        (Thu Jul 18 10:21:42 2013)

继续

4

1 回答 1

4

尝试:

INSERT INTO tbproppayh (id_payment)
SELECT s.id_payment
FROM   session.set_values s
WHERE  id_payment IS NOT NULL;  

WHERE EXISTS需要一个子查询:

WHERE EXISTS (SELECT ... FROM ...)

请参阅此示例

在您发表评论后,只需使用DISTINCT以避免插入重复值:

INSERT INTO tbproppayh (id_payment)
SELECT DISTINCT s.id_payment
FROM   session.set_values s
WHERE  id_payment IS NOT NULL;  
于 2013-07-18T09:35:10.817 回答