查询:表名指定多次

时间:2019-07-12 07:28:33

标签: laravel vue.js filter

我正在尝试修复Vue过滤器。我必须更改查询,但是在laravel目录中找不到它。

SELECT
    count(*) AS aggregate
FROM (
    SELECT
        ST_asGeoJSON(elements.geom) AS geometry
    FROM
        "elements"
    LEFT JOIN subsidies ON elements.subsidy_id = subsidies.id
    LEFT JOIN owners ON elements.owner_id = owners.id
    LEFT JOIN locations ON elements.location_id = locations.id
    LEFT JOIN element_type ON elements.element_type_id = element_type.id
    LEFT JOIN shapes ON elements.shape_id = shapes.id
    LEFT JOIN objectives ON elements.objective_id = objectives.id
    LEFT JOIN diameters ON elements.diameter_id = diameters.id
    LEFT JOIN maintenances ON maintenances.element_id = elements.id
    LEFT JOIN maintenances ON elements.id = maintenances.element_id
WHERE
    elements.organisation_id = 14
    and(elements.deleted_at) IS NULL
GROUP BY
    elements.id,
    maintenances.element_id,
    subsidies.id,
    owners.id,
    locations.id,
    element_type.id,
    shapes.id,
    objectives.id,
    diameters.id,
    maintenances.id
HAVING
    COUNT(element_id) < 1) count_row_table

上方是在选中复选框时执行的查询:

  

SQLSTATE [42712]:重复的别名:7错误:表名“维护”指定的次数超过一次(SQL:选择count(*)为...

['parent_table' => 'elements', 'join_table' => 'element_type', 'filter_column' => 'element_type_id', 'filter_value' => 'element_type_' . \Config::get('app.locale')],
['parent_table' => 'elements', 'join_table' => 'shapes', 'filter_column' => 'shape_id', 'filter_value' => 'shape_' . \Config::get('app.locale')],
['parent_table' => 'elements', 'join_table' => 'objectives', 'filter_column' => 'objective_id', 'filter_value' => 'objective_' . \Config::get('app.locale')],
['parent_table' => 'elements', 'join_table' => 'diameters', 'filter_column' => 'diameter_id', 'filter_value' => 'diameter', 'order_by' => 'diameters.id'],
['parent_table' => 'element_flora', 'join_table' => 'flora', 'filter_column' => 'flora_id', 'filter_value' => 'flora_' . \Config::get('app.locale'), 'additional_wheres' => ['element_flora.deleted_at is null']],
['parent_table' => 'element_fauna', 'join_table' => 'fauna', 'filter_column' => 'fauna_id', 'filter_value' => 'fauna_' . \Config::get('app.locale'), 'additional_wheres' => ['element_fauna.approval_pending is not TRUE', 'element_fauna.deleted_at is null']],
['parent_table' => 'elements', 'join_table' => 'owners', 'filter_column' => 'owner_id', 'filter_value' => 'owner'],
['parent_table' => 'maintenances', 'join_table' => 'elements', 'filter_column' => 'id', 'filter_value' => 'id', 'havingRaw' => 'COUNT(maintenances.element_id) < 1', 'join_type' => 'left', 'filter_null' => true],
['parent_table' => 'elements', 'join_table' => 'projects', 'filter_column' => 'project_id', 'filter_value' => 'project', 'order_by' => 'projects.id'],

0 个答案:

没有答案