Reputation: 33
I need to insert a new row into one table CUSTOMER_NOTES
for each row in another table CUSTOMER
that meets a condition.
If CUSTOMER
table column CURRENT
is marked as 1, then I need to shove a note into the CUSTOMER_NOTES
table, like "THIS IS A CURRENT CUSTOMER". So, if there are 50 current customers (and 240 total customers), there would be 50 entries shoved into the CUSTOMER_NOTES
table with the VALUE being "THIS IS A CURRENT CUSTOMER".
Upvotes: 1
Views: 3112
Reputation: 31879
Assuming your CUSTOMER
and CUSTOMER_NOTES
has a column CUSTOMER_ID
:
INSERT INTO CUSTOMER_NOTES(
CUSTOMER_ID,
NOTES
)
SELECT
CUSTOMER_ID,
'THIS IS A CURRENT CUSTOMER'
FROM CUSTOMER
WHERE
[CURRENT] = 1
Upvotes: 3