Jump to content

Delete subs help


UnknownPlayer

Recommended Posts

Hi,

i need help with command to delete id from episodes and episode_links, when delete season..

 

I have this table:

Season(for tv shows):

where i have id, name, date fields

 

Episodes:

where i have id, season_id, name, date fields

 

Episode_links:

where i have id, episode_id, link, date fields

 

Now i need help with command, when i delete season with id 1, to delete episodes where season_id is 1 and to delete episode_links where episode_id is id from table episodes where season_id = 1 ?

 

If you understand me, please help me ?

 

I tried with this:

$season = $_GET['season'];
$query = "DELETE FROM seasons WHERE id = '$season'";
$result = mysql_query($query, $connection);
if ($result) {
$query = "DELETE FROM episodes e, episode_links l WHERE e.season_id = '$season' AND l.episode_id = e.id";
$result = mysql_query($query, $connection);
}

but it doesn't work :/

Link to comment
Share on other sites

you may have to do a SELECT query to establish an array of all the existing rows that fall into those constants.. then run a delete on a per row basis using the results from your SELECT Query.. Or build a long delete query dynamicly through the results of the SELECT then run a single query with the delete that way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.