這是我的查詢,我要插入這應該從另一個表中選擇的值:插入並選擇組合不工作
insert into payment_details_kohin(installment_no)
values(
select count(installment_amount)+2
from kohin_plan.payment_details_insert
where customer_id='KBP100058'
)
...但它給我一個錯誤:
Msg 515, Level 16, State 2, Line 1 Cannot insert the value NULL into column 'customer_id', table 'kohinoor_rdfd.kohin_plan.payment_details_kohin'; column does not allow nulls. INSERT fails. The statement has been terminated.
當我嘗試以下查詢:
insert into payment_details_kohin(installment_no)
values(
select count(installment_amount)+2
from kohin_plan.payment_details_insert
where customer_id='KBP100058'
)
...它給了我下面的錯誤
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'.
親愛的朋友檢查我的文章會爲工作你 – Developerzzz
只需刪除'值' – Hoh