简体   繁体   中英

Combine Insert from Select with sysdate on Date column

I need to make an insert statement from a select statement, it looks like this

INSERT INTO kasa.customer (ctt_id, ntt_id) 
            (SELECT ctt_id, ntt_id FROM ctt WHERE ntt_id=2242456)

In this insert, I would also like to set a Date column to sysdate . Right now I'm doing it in two steps, but I've got a feeling this should be pretty easy to combine.

UPDATE kasa.customer SET created_dtm=sysdate WHERE ntt_id=2242456

Thanks

INSERT INTO kasa.customer (ctt_id, ntt_id, created_dtm) 
            (SELECT ctt_id, ntt_id, sysdate FROM ctt WHERE ntt_id=2242456)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM