insert into frombook([from],bookid,stocknum,seat,isupdated,discount) values (11,select bookid from books where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11),5,'0',0,80)消息 156,级别 15,状态 1,第 1 行
关键字 'select' 附近有语法错误。
消息 102,级别 15,状态 1,第 1 行
',' 附近有语法错误。
一看代码就知道 我想干什么操作

解决方案 »

  1.   

    INSERT INTO tb VALUES(xx,xx,xxx)SELECT INTO tb SELECT xx,xx FROM xx
      

  2.   

    insert into frombook([from],bookid,stocknum,seat,isupdated,discount) 
    select 11,bookid,5,'0',0,80 
    from books 
    where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
      

  3.   

    insert into frombook([from],bookid,stocknum,seat,isupdated,discount) 
    select 11, bookid,5,'0',0,80 from books where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
      

  4.   

    insert into frombook values 
    select 11,bookid ,5,'0',0,80
    from books 
    where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
    (11,select bookid from books where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11),5,'0',0,80)
      

  5.   

    --上面忘记删掉VALUES了
    insert into frombook ([from],bookid,stocknum,seat,isupdated,discount) 
    select 11,bookid ,5,'0',0,80
    from books 
    where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
    (11,select bookid from books where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11),5,'0',0,80)
      

  6.   

    insert into frombook([from],bookid,stocknum,seat,isupdated,discount)
    select 11,bookid,5,'0',0,80
    from books
    where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
      

  7.   

    insert into frombook([from],bookid,stocknum,seat,isupdated,discount) 
    select 11, bookid,5,'0',0,80 from books where not exists (select * from frombook where frombook.bookid=books.bookid and [from]=11)
      

  8.   

    直接values 结果集会有问题吧
      

  9.   

    csdyyr 说的对  
    但是 不加values 为什么可以啊,
    解释一下