如何让此查询查询多个值?
这很有效。看最后一行:
SELECT part_groups, part_categories, critical_part, part_groups_count, project FROM
(SELECT part_groups.name as part_groups, part_groups.critical_part as critical_part, part_categories.name as part_categories, projects.action_code as project, COUNT(part_groups.id) as part_groups_count, to_tsvector(part_groups.name) || to_tsvector(part_categories.name) || to_tsvector(projects.action_code) as document
FROM part_groups
CROSS JOIN projects
CROSS JOIN phases
JOIN part_categories ON part_categories.id = part_groups.part_category_id
GROUP BY part_groups.name, part_groups.critical_part, part_categories.name, projects.action_code, phases.name)
p_search WHERE p_search.document @@ to_tsquery('queryOne');
这不起作用。最后一行:
SELECT part_groups, part_categories, critical_part, part_groups_count, project FROM
(SELECT part_groups.name as part_groups, part_groups.critical_part as critical_part, part_categories.name as part_categories, projects.action_code as project, COUNT(part_groups.id) as part_groups_count, to_tsvector(part_groups.name) || to_tsvector(part_categories.name) || to_tsvector(projects.action_code) as document
FROM part_groups
CROSS JOIN projects
CROSS JOIN phases
JOIN part_categories ON part_categories.id = part_groups.part_category_id
GROUP BY part_groups.name, part_groups.critical_part, part_categories.name, projects.action_code, phases.name)
p_search WHERE p_search.document @@ to_tsquery('queryOne', 'queryTwo');
答案 0 :(得分:1)
我不知道to_tsquery
需要多个查询参数。试试这个:
WHERE p_search.document @@ to_tsquery('queryOne | queryTwo')
或
WHERE p_search.document @@ to_tsquery('queryOne & queryTwo')
取决于你的意图。