Good afternoon.
I am doing a website and a database for my practice, together with a colleague. Among the functions of the web, there is an advanced search engine, with several options.
My problem arises in making a concrete query between 3 tables, which are (summarized):
Table "molecule": Id, Name, Molecular weight, etc. (..)
Table "biological activity": Id, Name
Intermediate table: idMolecula, idActivity_Biological
A molecule can have several activities and vice versa. The problem appears when I want to know which molecules have activity 1 and activity 5, for example.
SELECT DISTINCT m.Nombrefrom molecula as m join actividad_biologica_has_molecula as abm on abm.molecula_idMolecula=m.idMolecula join actividad_biologica as ab on ab.idActividad_Biologica=abm.Actividad_Biologica_idActividad_Biologica where ab.Nombre="Lorem" and ab.Nombre="Ipsum"
The problem is that I have manually checked that the molecule has both properties, but it does not show it to me. On the other hand, if I do it separately, there's no problem.