vendredi 1 juillet 2016

MySQL IMDB Filtering Release Dates

I have asked a similar question but I was advised to ask this separately. I'm working with the IMDB database and the release_dates table is setup like: +--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | movie_id | int(11) | YES | | NULL | | | release_date | varchar(255) | YES | | NULL | | +--------------+--------------+------+-----+---------+-------+ 2 rows in set (0.06 sec) movie_id release_date 2 USA:22 January 2006 3 USA:12 February 2006 4 USA:19 February 2006 5 USA:22 January 2006 6 USA:19 March 2006 However, there are some records that only have parts of the date: movie_id release_date 86 USA:June 2005 90 USA:2003 Which doesn't work with: SELECT str_to_date(substring_index(release_date, ':', -1), '%d %M %Y') FROM release_dates; because it causes the records that have only the year or month/year to come out NULL. My ideal result would be being able to filter out movies from before 1984, I'm just not sure how to accomplish this with the unfortunately fragmented data that I have. Thank you!

Aucun commentaire:

Enregistrer un commentaire