Re: Leech (?) content of mySQL tables
From: Michael Fesser (netizen_at_gmx.net)
Date: 12/20/04
- Next message: Quinonez: "Re: forms sessions email"
- Previous message: Steve Edwards: "Re: Multi Table Query Help"
- In reply to: knoak: "Leech (?) content of mySQL tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Quinonez: "Re: forms sessions email"
- Previous message: Steve Edwards: "Re: Multi Table Query Help"
- In reply to: knoak: "Leech (?) content of mySQL tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|