[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] MySQL help
- Subject: [ale] MySQL help
- From: deepbsd.ale at gmail.com (David S Jackson)
- Date: Fri, 13 Mar 2015 13:52:09 -0400
Hi,
I'm a MySQL newbie. I'm just starting to use Python to talk to MySQL
databases, but first I need to understand the MySQL query language!
So, I have two tables: (zoo) animal and food.
animal has the columns ID, NAME, FAMILY, WEIGHT
food has ID, ANIMALID, FEED
So if I go: select id, name, family, feed from animal JOIN food ON
animal.id=food.animalid;
I get something like:
ID NAME FAMILY FEED
1 Seymore Snake mice, leaves
2 Gerard Giraffe leaves, grass
...
etc
So, if I have a situation where I want to see whether an animal has been
added the animal table but may have not been added to the food table,
how would I compose that query?
That is, the animal could have been added to the animal table and could
get an id, say 10, but the food table could have 20 foods already
entered and the animal-id would be used several times.
I was thinking, is there a way I can ask, "does the highest animal.id
number equal the highest food.animalid number"? If not, what animal is
not getting fed?
Dave