-1

さて、私には 4 つのテーブルがあり、最初の 2 つを結合してから、他の 2 つのテーブルとの別のユニオンとの内部結合を行う必要があります。行き詰まっています。とにかくありがとう

SELECT miRNA, Gene_Symbol FROM 
(SELECT cons.miRNA, cons.Gene_Symbol 
FROM conserved_site_context_scores cons
WHERE cons.miRNA = 'hsa-miR-29c'
UNION 
SELECT noncons.miRNA , noncons.Gene_Symbol 
FROM nonconserved_site_context_scores noncons
WHERE noncons.miRNA = 'hsa-miR-29c'
) AS targetScan

SELECT mirna_name, gene_symbol FROM (
SELECT sc.mirna_name, sc.gene_symbol
FROM hg19_predictions_s_c_aug2010 sc
WHERE sc.mirna_name = 'hsa-miR-29c'
UNION
SELECT oc.mirna_name, oc.gene_symbol
FROM hg19_predictions_0_c_aug2010 oc
WHERE oc.mirna_name ='hsa-miR-29c'
) AS microRNA

INNER JOIN microRNA
ON targetScan.miRNA = microRNA.mirna_name
WHERE targetScan.miRNA = 'hsa-miR-29c';
4

2 に答える 2

1

JOIN上記の2つのUNIONステートメントの方法を理解しようとしていると思いますか?もしそうなら、これを試してみてください:

SELECT miRNA, Gene_Symbol 
FROM 
   (
   SELECT cons.miRNA, cons.Gene_Symbol 
   FROM conserved_site_context_scores cons
   WHERE cons.miRNA = 'hsa-miR-29c'
   UNION 
   SELECT noncons.miRNA , noncons.Gene_Symbol 
   FROM nonconserved_site_context_scores noncons
   WHERE noncons.miRNA = 'hsa-miR-29c'
) AS targetScan INNER JOIN
   (
   SELECT mirna_name, gene_symbol 
   FROM (
      SELECT sc.mirna_name, sc.gene_symbol
      FROM hg19_predictions_s_c_aug2010 sc
      WHERE sc.mirna_name = 'hsa-miR-29c'
      UNION
      SELECT oc.mirna_name, oc.gene_symbol
      FROM hg19_predictions_0_c_aug2010 oc
      WHERE oc.mirna_name ='hsa-miR-29c'
   ) AS microRNA
      ON targetScan.miRNA = microRNA.mirna_name
WHERE targetScan.miRNA = 'hsa-miR-29c';

WHEREに既に含まれているため、下部の最終基準は必要ないと思いますUNION

于 2013-03-22T04:19:46.153 に答える
1

これを試して:

SELECT miRNA, Gene_Symbol
FROM (
       SELECT cons.miRNA, cons.Gene_Symbol
       FROM conserved_site_context_scores cons
       WHERE cons.miRNA = 'hsa-miR-29c'

       UNION

       SELECT noncons.miRNA, noncons.Gene_Symbol
       FROM nonconserved_site_context_scores noncons
       WHERE noncons.miRNA = 'hsa-miR-29c'
    ) AS targetScan
Inner Join
(
   SELECT mirna_name, gene_symbol
   FROM (
    SELECT sc.mirna_name, sc.gene_symbol
    FROM hg19_predictions_s_c_aug2010 sc
    WHERE sc.mirna_name = 'hsa-miR-29c'

    UNION

    SELECT oc.mirna_name, oc.gene_symbol
    FROM hg19_predictions_0_c_aug2010 oc
    WHERE oc.mirna_name = 'hsa-miR-29c'
    )tbl 
)AS microRNA
    ON targetScan.miRNA = microRNA.mirna_name
WHERE targetScan.miRNA = 'hsa-miR-29c';
于 2013-03-22T04:23:35.627 に答える