2012-05-13 21 views
1

私は複数のselect文または値を挿入する必要があります。 2番目の列名(notication_timestamp)を削除すると、次のように動作します。複数選択挿入

insert into notification (msg,notification_timestamp) select msg from data; 

は、私が言うことができるようにしたい:

insert into notification (msg,notification_timestamp) values (select msg from data,now()); 

しかし、それは動作しません。何か案は?

答えて

2

あなたが選択クエリに

insert into notification (msg,notification_timestamp) select msg,'value for notification_timestamp' from data; 

notification_timestampを入れていなかったので、それが

insert into notification (msg,notification_timestamp) select msg,now() from data; 
+0

notification_timestampは、すべてのクエリではありません。 ..別個のデータ。 – user983223

+0

@ user983223私の編集した投稿を見てください –

+0

もし私が別のランダムな列と値を挿入してOKにしたいのであれば...それはクエリに無関係ですが選択したままにしておきますか? – user983223

5

値の文を削除可能性があります

Insert into notification(msg, notification_timestamp) 
    Select msg, now() 
    from data