Hey guys, quick question. I have a movie table which records information about certain movies. See below for the table structure.

id Title Length
-------------------------------------------
1 American Pie 160
2 Van Wilder 115
3 Not Another Teen Movie 115
4, Road Trip 130
5 Shawshank Redemption 130
6 Scarey Movie 3 150

How can I get the title of the films that are the same length as another
film? Eg, a query which displays Van Widler and Shawshank Redemption.

I've tried using GROUP BY-HAVING's and such. I just can't seem to work it out.
Any help would be greately appreciated!

You'll need to create a query that joins the table with itself on the Length field.

SELECT movie.Title, movie.Length, movie_1.Title
FROM movie LEFT JOIN movie AS movie_1 ON movie.Length = movie_1.Length;

The first column lists the movie and the third column lists the movies with the same length as the movie in the first column.

Thanks heaps mate. I would of never worked that out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.