Hello. Newbie here.
So ,
lets just say that
There is animals with ID, Name and a Foreign Key that is Species ID.
so that would be like
animal
animalID animalname Species_specID(FK)
another one would be species ID and name
species
specID specname
another one would be diet Id and number of feeds per day
diet
dietID numberoffeed
and the last one would be the table for diet and animal
diet_feeds_animals
diet_dietID(Fk) animal_animalID(Fk)
and the goal is to find how many of the specIDs is getting fed with number of feeds example (3 feeds perday)
but since there can be no relation to diet and species. how can i find that?
What I have tried:
i tried using joins but feels like , i am using it wrong
my code looks like this
select count(species.specID) as Total_species
From mydb.species
inner join animal on
species.specID = animal.species_specID
inner join diet_feeds_animal on
animal_animalID = diet_dietID
inner join diet on
diet.dietID = species.specID
where numberoffeed>3;
but this one keeps returning 0 as value. Can someone explain to me?