开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜