1 回答
TA贡献2065条经验 获得超14个赞
更改为您的对象名称。我将数据放入前面的WITH子句中,我将标记“真实”查询的开始位置。不过,您没有指定您想要的输出,所以我只是假设了一些内容。我使用了与您的第一个搜索短语相匹配的数据。
WITH
-- input ....
phrases(id,phrase) AS (
SELECT 1,'buildawall'
UNION ALL SELECT 2,'redtree'
UNION ALL SELECT 3,'countonyou'
UNION ALL SELECT 4,'purchaseanapple'
)
,
adjectiveverblist (id,word,type) AS (
SELECT 1,'build' ,'verb'
UNION ALL SELECT 2,'red' ,'adjective'
UNION ALL SELECT 3,'count' ,'verb'
UNION ALL SELECT 4,'purchase' ,'verb'
)
,
nounlist(id,word) AS (
SELECT 1,'wall'
UNION ALL SELECT 2,'tree'
UNION ALL SELECT 3,'you'
UNION ALL SELECT 4,'apple'
)
-- end of input - real query starts here ...
SELECT
phrase
, av.word AS adjective_verb
, av.type AS av_type
, n.word AS noun
FROM phrases
JOIN adjectiveverblist av ON phrase LIKE '%' + av.word + '%'
JOIN nounlist n ON phrase LIKE '%' + n.word + '%'
;
-- out phrase | adjective_verb | av_type | noun
-- out -----------------+----------------+-----------+-------
-- out redtree | red | adjective | tree
-- out buildawall | build | verb | wall
-- out countonyou | count | verb | you
-- out purchaseanapple | purchase | verb | apple
- 1 回答
- 0 关注
- 91 浏览
添加回答
举报