我需要在laravel中编写此查询,但我不知道如何编写它
Select RANKED.rankTotal*MATCHED.Popularity score
, urlID
from
( SELECT sum(rank) as rankTotal
, urlID
FROM searchengine.indexer
where keyword IN("there","is")
group
by urlID
) RANKED
,
( Select ID
, Popularity
From searchengine.visitedpages
where document LIKE '%there is%'
) MATCHED
where RANKED.urlID = MATCHED.ID ;
答案 0 :(得分:-1)
看看这是否适合你。
$query = \DB::raw("Select RANKED.rankTotal*MATCHED.Popularity as score, urlID from (SELECT
sum(rank) as rankTotal,urlID
FROM searchengine.indexer
where (keyword=? or keyword=?) group by urlID ) as RANKED,
(Select ID, Popularity
From searchengine.visitedpages where document LIKE ?) as MATCHED
where RANKED.urlID =MATCHED.ID ;");
$results = \DB::select($query, ['there', 'is', '%there is%']);