Leech (?) content of mySQL tables

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

Threaded View
Hi Micheal,

Thanks for the replies!

First of all, what do you mean with 'joining the tables' because they
have to be separate tables...

And I still have a question, because i just started on mySQL, as
you've probably guessed.
Anyway, i don't understand your query:

SELECT description, name                             <-understood
FROM animals LEFT JOIN species s ON (species = s.id) <- what's "left
join", and what's "ON (species = s.id)"
ORDER BY description, name                           <-understood

And what goes for the ON/OFF feauture, it's supposed to be an option
to disable animals, or entire species, whitout having to delete them,
so they can be activated again a lot faster if needed.

Thanks in advance for the great help!!

Greetings knoakske

Re: Leech (?) content of mySQL tables

knoak wrote:
Quoted text here. Click to load it

"joining the tables" is the term used to connect two (or more) tables
together logicaly in a SQL statement.

Michaels excellant 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

are both ways of joining the two tables, and are functionally identical.
The first one is probably easier to understand for a beginner SQL.

Basically the second example JOINS the tables ON the animals.species
column and species.id column.  (Dont worry too much about the LEFT join
just yet, there are other types of JOINS you can use which are scarier)

My advice, use the first syntax for now until you get some experience
under your belt.

Hope that helps :-)


Site Timeline