mysql fun! JOIN me ...
| From: | zerosumzero@yahoo.com | Date: | Thu, 05 Jul 1979 21:37:37 +0000 |
| Subject: | mysql fun! JOIN me ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56390@lists.php.net to get a copy of this message | ||
Question 1: is there a good explination online of how to use the JOIN
function in mysql? I've looked at the documentation:
http://www.mysql.com/doc/J/O/JOIN.html
but it's to confusing. It doesn't exactly what you are joining or why you
might want to do that ... I think JOIN is what I need, here is the problem:
So I have some tables:
create table maps
(
rowid INT(10) AUTO_INCREMENT PRIMARY KEY NOT NULL
);
create table locations
(
map INT(10), #map rowid
rowid INT(10) AUTO_INCREMENT PRIMARY KEY NOT NULL
);
create table notes
(
location INT(10), ## location rowid
rowid INT(10) AUTO_INCREMENT PRIMARY KEY NOT NULL
);
Each map has many locations and each location has many notes ...
I want to delete the map, all of it's locations and all of the locations
notes.
clearing the maps and locations is easy:
$sql = "DELETE FROM maps WHERE (rowid='$mapid')";
$result = mysql_query($sql);
$sql = "DELETE FROM locations WHERE (map='$mapid')";
$result = mysql_query($sql);
but how to get rid of those notes?
I'm thinking of sending all of the location rowid(s) to an array then using
that array to delete the notes ... but I think this JOIN thing might let me
do it all with one query.
Can any of you kind folks help me here?