0

私はSQLの専門家ではありません。

この条件に相当するクエリを実装したい

If  ( (first-access-of-error1 = first-access-of-error2 and 
       second-access-of-error1 = second-access-of-error2) OR 
      (first-access-of-error1 = second-access-of-error2 and
       second-accessr-of-error1 = first-access-of-error2) )

私は次のようなものでそれを試みました:

select d.id,
       concat(a.variable_name,"|",a.file_url,"|",a.line_number,"|",a.stacktrace)
             as FirstAccess_Params, 
       concat(b.variable_name,"|",b.file_url,"|",b.line_number,"|",b.stacktrace) 
             as SecondA_Params 
from defect d 
right join (accessor a, accessor b) 
   on (d.id=a.defect_id and d.id=b.defect_id and a.id<b.id) 
where d.category_id=0 and d.relationship_id!=-1 
group by FirstAccess_Params,SecondA_Params

上記のクエリを使用すると、この条件を解決できます。

(first-access-of-error1 = first-access-of-error2 and 
 second-access-of-error1 = second-access-of-error2)

しかし、私はこの条件を達成する方法のような問題を抱えています:

(first-access-of-error1 = second-access-of-error2 and
 second-accessr-of-error1 = first-access-of-error2)

何か助けていただければ幸いです。どんなアイデアでも大歓迎です..

これは、アクセサー テーブルのスキーマです。

<createTable tableName="accessor">
        <column autoIncrement="true" name="id" type="BIGINT UNSIGNED">
            <constraints nullable="false" primaryKey="true"/>
        </column>
        <column name="defect_id" type="BIGINT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="operation" type="TINYINT UNSIGNED"/>
        <column name="variable_name" type="VARCHAR(128)"/>
        <column name="object_address" type="VARCHAR(64)"/>
        <column name="type" type="TINYINT UNSIGNED"/>
        <column name="module_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="file_url" type="VARCHAR(256)"/>
        <column name="function_name" type="VARCHAR(64)"/>
        <column name="line_number" type="SMALLINT UNSIGNED"/>
        <column name="accessing_order" type="TINYINT UNSIGNED"/>
        <column name="stacktrace_type" type="TINYINT UNSIGNED"/>
        <column name="stacktrace" type="VARCHAR(2048)"/>
        <column name="parameter" type="VARCHAR(5120)"/>
    </createTable>

そして、これは欠陥テーブルのスキーマです

<createTable tableName="defect">
        <column autoIncrement="true" name="id" type="BIGINT UNSIGNED">
            <constraints nullable="false" primaryKey="true"/>
        </column>
        <column defaultValueNumeric="0" name="rule_id" type="SMALLINT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column defaultValueBoolean="false" name="hide" type="BIT">
            <constraints nullable="false"/>
        </column>
        <column defaultValueNumeric="0" name="relationship_id" type="BIGINT">
            <constraints nullable="false"/>
        </column>
        <column name="category_id" type="SMALLINT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="sub_category_id" type="SMALLINT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="module1_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="module2_id" type="INT UNSIGNED"/>
        <column name="execution_instance_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="application_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="project_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="target_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="testsuite_id" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="timestamp" type="INT UNSIGNED">
            <constraints nullable="false"/>
        </column>
        <column name="priority" type="BIT"/>
        <column name="status" type="BIT"/>
        <column name="assignee" type="VARCHAR(64)"/>
        <column name="label_ids" type="VARCHAR(1024)"/>
        <column name="remark" type="VARCHAR(512)"/>
        <column name="accessor_ids" type="VARCHAR(1024)"/>
        <column name="parameter" type="VARCHAR(2048)"/>
        <column defaultValueNumeric="0" name="parent_id" type="BIGINT">
            <constraints nullable="false"/>
        </column>
    </createTable>
4

2 に答える 2