Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:31:51+00:00 2026-06-18T05:31:51+00:00

I have a SQL statement that does nearly what I want. What I need

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:31:53+00:00Added an answer on June 18, 2026 at 5:31 am

    Try something like this — uses a subquery to get only the desired genus:

    SELECT *
    FROM insecta10000 i 
      JOIN 
      (
      SELECT genus
      FROM insecta10000
      WHERE pindent > 60
        AND coverage > 60
        AND qseqid in ("diaci0.9_transcript_99990000013040", "diaci0.9_transcript_99990000022677")
      GROUP BY genus
      HAVING COUNT(*) = 2
      ) i2 on i.genus = i2.genus 
    

    And here is the SQL Fiddle.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL statement (MS SQL Server 2005) that does a simple calculation
I have to following SQL Statement that I want to conver to LINQ Select
I have the following sql statement that I need to make quicker. There are
I have a T-SQL statement that basically does an insert and OUTPUTs some of
I have a sql function that does a simple sql select statement: CREATE OR
I have an interface that I want to allow an arbitrary SQL select statement
I have a sql statement that concatenates two columns, ItemNumber and Name, into one
I have a sql statement that uses Difference => http://msdn.microsoft.com/en-us/library/ms188753.aspx I do this in
I have an SQL statement that I'm executing through OleDb, the statement is something
I have an sql statement that is supposed to return 2 rows. the first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.