2

I have a MySql table having the following structure:

ontology_term
pathway_id
pathway_name

I want to write a query using which we can get mapping between various pathways (having unique id's -> pathway_id) based on the number of common ontology terms.

So the output should be,

Pathway_id1, Pathway_id2, No. of common terms

I know, it can be easily done using a server side language, will it be faster to use MySql instead?

1
  • Can you provide some example data that relates to your expected output? Commented Jun 29, 2010 at 16:47

1 Answer 1

1

If I understood you right, that is

select a.pathway_id, b.pathway_id, count(*)
from t a
inner join t b on a.ontology_term = b.ontology_term
group by a.pathway_id, b.pathway_id

There is no record if two pathways do not have common terms

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this works. However, I added another condition "AND a.pw_id != b.pw_id" else it will also group each pathway by itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.