0

存在を使用するようにこのクエリを変更するにはどうすればよいですか?

SELECT allele.allele as allele,site.allele_id as allele_id, site.genome_site_id as genome_site_id, popl.popl_id as popl_id,popl.frequency as frequency 
FROM kref.allele as allele 
    join kref.genome_site_allele as site using (allele_id) 
    LEFT JOIN kref.genome_site_allele_popl as popl USING (ref_genome_id, allelism_start, allelism_end, chrom_id, allele_id) 
WHERE ref_genome_id= 2 AND allelism_start=25710014 AND allelism_end=25710015 
    AND chrom_id ='22' 
    AND site.allele_id IN (
        SELECT allele_id 
        from kref.allele 
        where allele IN ('-','C' )
    )
4

1 に答える 1

1

なんらかの理由で、EXISTS を使用した意味的に同等のクエリを次に示します。

SELECT allele.allele as allele,site.allele_id as allele_id,
       site.genome_site_id as genome_site_id, popl.popl_id as popl_id,
       popl.frequency as frequency
  FROM kref.allele as allele
  JOIN kref.genome_site_allele as site using (allele_id)
  LEFT JOIN kref.genome_site_allele_popl as popl
      USING (ref_genome_id, allelism_start, allelism_end, chrom_id, allele_id)
 WHERE ref_genome_id= 2 
   AND allelism_start=25710014
   AND allelism_end=25710015
   AND chrom_id ='22'
   AND EXISTS (
     SELECT TRUE
     FROM kref.allele
     WHERE allele IN ('-','C')
     AND allele_id = site.allele_id
   )
于 2012-11-08T15:15:14.247 に答える