ok, here are the 3 tables i have that are related:

mysql> desc poll_questions;
+----------------+-----------------+------+-----+------------+--------------
--+
| Field          | Type            | Null | Key | Default    | Extra
|
+----------------+-----------------+------+-----+------------+--------------
--+
| poll_id        | int(9) unsigned |      | PRI | NULL       |
auto_increment |
| aim_screenname | varchar(16)     |      | MUL |            |
|
| question       | varchar(255)    |      |     |            |
|
| date_created   | date            |      |     | 0000-00-00 |
|
+----------------+-----------------+------+-----+------------+--------------
--+

mysql> desc poll_answers;
+-----------+------------------+------+-----+---------+----------------+
| Field     | Type             | Null | Key | Default | Extra          |
+-----------+------------------+------+-----+---------+----------------+
| answer_id | int(12) unsigned |      | PRI | NULL    | auto_increment |
| poll_id   | int(9) unsigned  |      |     | 0       |                |
| answer    | varchar(255)     |      |     |         |                |
+-----------+------------------+------+-----+---------+----------------+

mysql> desc poll_votes;
+----------------+------------------+------+-----+---------+-------+
| Field          | Type             | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------+-------+
| aim_screenname | varchar(16)      |      | PRI |         |       |
| answer_id      | int(12) unsigned |      | PRI | 0       |       |
| time_voted     | timestamp(12)    | YES  |     | NULL    |       |
| voter_ip       | varchar(15)      |      |     |         |       |
+----------------+------------------+------+-----+---------+-------+

I'm pretty sure this is completely normalized. I have no problem joining the
3 tables to do SELECTS...but what happens when I want to delete a poll? I
can easily elete from the poll_questions and poll_answers tables, but how do
I delete the necessary rows in the poll_votes table? I tried doing a DELETE
query just like a SELECT, but it didn't work:

DELETE FROM poll_votes AS v, poll_answers AS a, poll_questions AS q
        WHERE (q.poll_id = 1) AND (v.answer_id = a.answer_id) AND (a.poll_id =
q.poll_id);

Please help! Thanks!


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to