What is the problem in this query?
insert into fatora
(item_id , item_name , items_number , item_dis , item_sell, fatora_type )
values
( (Select item_id , item_name , item_number , item_dis , item_dis from helper) , 1)
It gives me this error :
Msg 116, Level 16, State 1, Line 2 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Msg 109, Level 15, State 1, Line 1 There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
CodePudding user response:
In an SQL select query you can use literal values instead of column names. So in your case when you want each new row to have fatora_type
set to 1 you can use the following:
insert into fatora
(item_id, item_name, items_number, item_dis, item_sell, fatora_type)
Select item_id, item_name, item_number, item_dis, item_dis, 1 from helpe
CodePudding user response:
You are missing a value for the fatora_type column in the select clause.