For a Band website I have to insert records into a table “release_lyrics”:
CREATE TABLE IF NOT EXISTS `release_lyrics` (
`lyric_id` smallint(2) NOT NULL auto_increment,
`release_id` smallint(2) NOT NULL,
`track_id` smallint(2) NOT NULL,
`lyrics` text,
PRIMARY KEY (`lyric_id`),
FOREIGN KEY (`release_id`) REFERENCES `releases` (`release_id`) ON DELETE CASCADE,
FOREIGN KEY (`track_id`) REFERENCES `release_tracks` (`track_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
The values for release_id and track_id are filled with data from the tables releases and release_tracks represented in drop down menus. The question I have is about the query populating the tracks drop down menu coming from the table release_tracks:
CREATE TABLE IF NOT EXISTS `release_tracks` (
`track_id` smallint(2) NOT NULL auto_increment,
`release_id` smallint(2) NOT NULL,
`track_name` varchar(128) default NULL,
`track_file` varchar(128) default NULL,
PRIMARY KEY (`track_id`),
FOREIGN KEY (`release_id`) REFERENCES `releases` (`release_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I need to make a query in such a way that, when I add other lyrics for the same album, the track_id(s) that is/are already in the table release_lyrics is/are not longer appearing in the tracks drop down menu. So somehow I have to Join the tables release_tracks and release_lyrics but I have no idea how?
Thank tou in advance.