开发者

Insert SQL on based on field from ALL records

开发者 https://www.devze.com 2023-03-19 02:04 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消