Re: Leech (?) content of mySQL tables

From: Michael Fesser (netizen_at_gmx.net)
Date: 12/20/04


Date: Mon, 20 Dec 2004 18:16:07 +0100


 .oO(knoak)

>Well, thank you both for your reaction. I looked at Pedro's option,
>but i do not wish to work with UPDATE, because that would only slow
>down queries. (thanks for the effort anyway..)

Eh? Of course you only have to use UPDATE when you actually want to
update something, like changing the species name from 'birds' to 'flying
animals'.

>What my main goal is to be able to sort the animals by name of the
>species.
>Of course the species is referred to as an ID number. If species are
>birds (id 1), fishes (id 2), and ants (id 3),
>
>The ouput has to be: Instead of:
>Forest ant (ants) Eagle
>Red ant (ants) Forest Ant
>Hawk (birds) Hawk
>Eagle (birds) Red Ant
>Shark (fishes) Shark
>Whale (fishes) Whale
>
>So the animals have to be ordered by something that's not in their
>own table,

Easy. After joining the species and animals tables together you can sort
on whatever column(s) you like. From Pedro's example:

SELECT s.description, a.name
FROM species s, animals a
WHERE a.species=s.id
ORDER BY s.description, a.name

or something like

SELECT description, name
FROM animals LEFT JOIN species s ON (species = s.id)
ORDER BY description, name

>Later on, the website's admin has to be able to turn species AND
>animals on and off

Will this be used just for a query to restrict the search result or is
it going to be stored in the database permanently?

>, so the query should be this in theory:
>SELECT species_names, animal_names FROM animals WHERE
>species_status=on AND animal_status=on ORDER BY species_name
>
>Where the species_names and species_status are only defined in the
>'species'-table.

Should be no problem.

Micha



Relevant Pages

  • Re: Aggression, human nature and paleopsychology
    ... Instincts are not good or bad in themselves but more or less ... Human beings share with other animals instinctual inhibitions against ... killing members of our own species. ... > human aggression also raises some basic and profound questions ...
    (sci.bio.evolution)
  • Zoo Torah: Correction, and The Religion of Conservation Part II
    ... The Religion of Conservation, Part II ... "Even the least of creatures should be extremely important in his eyes ... species is surviving, not if any given individual is surviving. ... though it did allow the slaughter of animals of that species. ...
    (soc.culture.jewish.moderated)
  • Re: Zoo Torah: The Religion of Conservation, part one
    ... >>> it was a protected species. ... many people take conservation very seriously. ... And does Judaism have anything to say ... Animals and plants can be of tremendous value to mankind in many ...
    (soc.culture.jewish.moderated)
  • Interview with E.O. Wilson
    ... Konrad Lorenz wrote that animals of the same species sometimes by ... mortali­ty due to direct aggression during war in the modern area. ... There are about 9.500 known species of ants, many of whom you studied, ...
    (sci.bio.evolution)
  • Re: Evolution and Love
    ... >> dynamics in a particular species, based on their habitat, diet etc. ... > invest a lot of resources in each, while r selected animals have many ... > According to the parental investment theory, ... >> Monogamy is not a universal trait though, it exists in species where it ...
    (sci.bio.evolution)