开发者

Using subquery as value in mysql

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

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'开发者_StackOverflow中文版)

Is that possible without procedures?


Something like this should work for you:

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


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

0

精彩评论

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