Insert SQL on based on field from ALL records
I have seen this done when moving a table, but it uses the entire select subquery as the values input. I need to do something similar to this:
INSERT INTO customer_alerts
(message, customer_id)
VALUES
("Message HERE", (SELECT Customer.id from Custom开发者_如何学Goers as Customer))
Any ideas on how to achieve this?
Use:
INSERT INTO customer_alerts
(message, customer_id)
SELECT 'Message HERE', c.id
FROM CUSTOMERS c
You can statically define values in the SELECT
clause.
精彩评论