简体   繁体   中英

Using subquery as value in mysql

I'm looking for a way to quickly process some table in mysql 5.0.X. I'd like to insert a row into t1 for each row in t2 . Essentially, I'd like something like this to map over every row:

REPLACE INTO t1 VALUES (CONCAT('blah/', (select username from t2)), 'value')

Is that possible without procedures?

Sounds like you are looking for the INSERT SELECT statement unless I am misunderstanding. Check this link for details.

Something like this should work for you:

REPLACE INTO t1
SELECT CONCAT('blah/',username), 'value'
FROM t2

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