
Untitled
By: a guest on
Jul 4th, 2012 | syntax:
SQL | size: 0.54 KB | hits: 17 | expires: Never
SELECT SUM(i.score * t.COUNT) AS score
FROM search_index i
INNER JOIN search_total t ON i.word = t.word
INNER JOIN node n ON n.nid = i.sid
INNER JOIN node_access na ON na.nid = n.nid
WHERE n.STATUS = 1
AND (na.grant_view >= 1
AND ((na.gid = 0 AND na.realm = 'all')
OR (na.gid = 1 AND na.realm = 'workflow_access')
OR (na.gid = 0 AND na.realm = 'workflow_access_owner')))
AND (i.word = 'sghsfghnsf')
AND i.TYPE = 'node'
GROUP BY i.TYPE, i.sid
HAVING COUNT(*) >= 1
ORDER BY score DESC LIMIT 0, 1