0

2つのテーブルを結合して出力を取得するMySQLJOINクエリがあります

select distinct (a.error_type),a.links_id, a.crawl_cycle , b.* from $table a inner join crawler_error_type b on a.error_type = b.error_type where a.projects_id = '$pid' and b.error_priority_page_level='High'

次に、フィールドの値がerror_type3番目のテーブルに存在するかどうかを確認します。それが存在する場合、結果の行は表示されないはずです。

4

3 に答える 3

0

次のようにもう1つ追加する必要がありINNER JOINますthird_table

SELECT DISTINCT a.error_type, a.links_id, a.crawl_cycle , b.* 
FROM  $table a 
      INNER JOIN crawler_error_type b 
          ON a.error_type = b.error_type 
      INNER JOIN third_table c
          ON a.error_type = c.error_type 

WHERE a.projects_id = '$pid' AND 
      b.error_priority_page_level='High'.
于 2012-07-25T07:27:42.220 に答える
0

以下を追加します。

LEFT OUTER JOIN third_table c ON c.error_type = a.error_type 

WHERE c.error_type is null

LEFT OUTER JOINは、third_tableで結合しているテーブルのすべてのレコードを表示します。third_tableのエラータイプが一致するレコードは必要ないため、次を使用します。WHERE c.error_type is null

于 2012-07-25T07:29:26.173 に答える
0

私がそれを正しく理解していれば、3番目のテーブルを内部結合できるはずです。内部結合は、結合テーブルにレコードがある場合、レコードを表示します。私が誤解している場合は、詳しく説明していただけますか。どうも

select distinct (a.error_type),a.links_id, a.crawl_cycle , b.* 

from $table a 

inner join crawler_error_type b on a.error_type = b.error_type 

inner join some_table_3 c on c.error_type = a.error_type 

where a.projects_id = '$pid' and b.error_priority_page_level='High'
于 2012-07-25T07:31:18.357 に答える