I have two tables company_list and company_details. The company_list table has a company_id column, and the company_details has some information related to the company with the company_id. I wanted to insert data into the company_details table with the company_id not in the company_details table.
I tried it with the following query but it gave me an error.
INSERT INTO company_details (company_id,detail_found)
VALUES ((SELECT company_id FROM company_list WHERE company_id  NOT IN (SELECT company_id FROM company_details)), 'No data found');
The error is:
Msg 512, Level 16, State 1, Line 27
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
How to insert data into the table with a subquery that returns more than one value?
 
    