RRPANDEY
RRPANDEY

Reputation: 235

mysql query to fetch film and its song from two table

I am using following code to fetch film and song from two films and songs table the issue is I can fetch only on song of that film using below query. but my requirement is to fetch all the songs of that film from song table which is having same filmid for its song.

$url=$_GET['url'];   
$sql = "SELECT * FROM films f    
inner join songs s on f.filmId = s.filmId    
WHERE f.url='$url'"; 

I also need to combine DATE_FORMAT(filmReleaseDate, '%d %M %Y' ) filmReleaseDate in above code

Table Structure

Film table

`filmId`,`filmName`,`url`,`director`,`actor`

Song table

`songId`,`songName`,`filmId`,`filmName`

Upvotes: 0

Views: 131

Answers (1)

harry
harry

Reputation: 1007

$url=$_GET['url'];   
$sql = "SELECT * FROM films f    
left join songs s on f.filmId = s.filmId    
WHERE f.url='$url'"; 

Upvotes: 1

Related Questions