I have a SQL statement that does nearly what I want. What I need is to find genus such that
pindent > 60 and coverage > 60 for both qseqid values. I think I need some type of join, maybe like in this question
Here is what I have now. Which does not achieve the result I want.
SELECT qseqid, genus, species, txid, sgi, pindent, coverage
FROM vmdavis.insecta10000
WHERE pindent > 60
AND coverage > 60
AND qseqid in ("diaci0.9_transcript_99990000013040", "diaci0.9_transcript_99990000022677")
ORDER BY genus, species, qseqid, coverage, pindent;
Here is an example of why this does not work. Anchon meets the above criteria for qseqid for dia...040 but not for dia...677 so I would not what this row.
| diaci0.9_transcript_99990000013040 | Anchon | sp. NYSM 95-02-01-35 | 265052 | 6467730 | 80.93 | 61.7597 |
Here is a sample of the table
mysql> SELECT qseqid, genus, species, txid, pindent, coverage FROM vmdavis.insecta10000 limit 5;
+------------------------------------+---------+-------------+--------+---------+----------+
| qseqid | genus | species | txid | pindent | coverage |
+------------------------------------+---------+-------------+--------+---------+----------+
| diaci0.9_transcript_99990000000055 | Apis | florea | 7463 | 97.5 | 2.58107 |
| diaci0.9_transcript_99990000000055 | Bombus | impatiens | 132113 | 97.5 | 3.3534 |
| diaci0.9_transcript_99990000000055 | Nasonia | vitripennis | 7425 | 97.5 | 1.58343 |
| diaci0.9_transcript_99990000000055 | Bombus | terrestris | 30195 | 97.5 | 3.41207 |
| diaci0.9_transcript_99990000000055 | Apis | mellifera | 7460 | 97.5 | 2.88889 |
+------------------------------------+---------+-------------+--------+---------+----------+
Here is an example. In this case genus Agetocera is listed twice because for both qseqid it meets the criteria for pindent and coverage. Niether of these rows should be listed if Agetocera did not meet the conditions of pindent > 60 and coverage > 60 for both qseqid
| qseqid | genus | species | txid | pindent | coverage
| diaci0.9_transcript_99990000013040 | Agetocera | mirablis | 715820 | 291191497 | 82.37 | 60.7963 |
| diaci0.9_transcript_99990000022677 | Agetocera | mirablis | 909986 | 309755769 | 77.52 | 78.6269 |
I am very new to mysql, I assume the answer to this question probably exists on stackoverflow. I just don't know what to search for or understand the solutions if I find it. If the question can be better ask or you can suggest a better title I will update.