我想做的最好是将其描述为SQL中的mad-libs,其中有一个列的行为类似于“模板”,将以其他列中的所有值插入正确的位置结尾。
下面是示例表的示例。最终查询应返回:昨天,我看到公园里有20只愤怒的猫在弹跳20件毛衣。2.如果Fish能够在进行7.5年的登月任务时奔跑,那真是太好笑了。
ID | Noun | Adjective | Verb | Number | Sentence
===================================================
1 | Cat | Angry | Bouncing | 20 | Yesterday, I saw [Number] [Adjective] [Noun]s [Verb] [Number] sweaters around the park.
2 | Fish | Hilarious | Run | 7.5 | It would be so [Adjective] if [Noun] could [Verb] while on a [Number] year mission to the moon.
这是一个[[傻]示例,就像疯狂的libs在现实生活中一样。不过,它表明了正在努力实现的目标。
replace()
和replace()
:select t.*,
replace(replace(replace(replace(sentence, '[noun]', noun
), '[verb]', verb
), '[Adjective]', Adjective
), '[Number]', number
) as filled_in
from t;