I have two tables.
ticket:
+--------------------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+-----------------+------+-----+---------+----------------+
| ticket_id | int(8) unsigned | NO | PRI | NULL | auto_increment |
| ticket_user_id | int(8) unsigned | NO | MUL | NULL | |
| ticket_status | varchar(6) | NO | | opened | |
| ticket_subject | varchar(100) | NO | MUL | NULL | |
| ticket_message | text | NO | | NULL | |
+--------------------+-----------------+------+-----+---------+----------------+
ticket_reply:
+------------------------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------+------+-----+---------+----------------+
| ticket_reply_id | int(8) unsigned | NO | PRI | NULL | auto_increment |
| ticket_reply_ticket_id | int(8) unsigned | NO | MUL | NULL | |
| ticket_reply_showname | varchar(40) | YES | | NULL | |
| ticket_reply_message | text | NO | | NULL | |
+------------------------+-----------------+------+-----+---------+----------------+
ticket_reply_ticket_id
correspond to ticket_id
to link these 2 tables.
In PHP, I have an $userId
and I need to delete all tickets from the ticket table of $userId
but also to delete all replies corresponding these tickets Id.
Is it possible to dot it in one or 2 sql request or do I have to make a delete of ticket_reply for each ticket_id of $userId
?
Thanks?