Leech (?) content of mySQL tables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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..)

So i looked at badr's option, and i'm really interested, but i found
out that somehow my host doesn't support INNODB types.

What my main goal is to be able to sort the animals by name of the
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, and ordering by species id also is impossible because they
not entered in alphabeticaly order...

Later on, the website's admin has to be able to turn species AND
animals on and off, 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

I hope it's clear, and that i'm not asking to much... (and that it's
not impossible...)

Greetings knoak

Re: Leech (?) content of mySQL tables


Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

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

Quoted text here. Click to load it

Should be no problem.


Site Timeline