1 回答

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個贊
更改為您的對象名稱。我將數(shù)據(jù)放入前面的WITH子句中,我將標(biāo)記“真實(shí)”查詢的開始位置。不過,您沒有指定您想要的輸出,所以我只是假設(shè)了一些內(nèi)容。我使用了與您的第一個搜索短語相匹配的數(shù)據(jù)。
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 關(guān)注
- 140 瀏覽
添加回答
舉報(bào)