in reply to DBI MySQL Join Question
The table after the words "LEFT JOIN" is the table from which you want to select all records even if they have a NULL value in one or more foreign key fields. If you want to take each Image record and join it to Regio and Insula wherever possible, then you need to swap the first two LEFT JOINs, like this:
my $sth = $dbh->prepare( "SELECT * FROM Images LEFT JOIN Images ON Images.RegioID = Regio.RegioID LEFT JOIN Images ON Images.InsulaID = Insula.InsulaID LEFT JOIN ImgThemes ON Images.ImageID = ImgThemes.ImageID LEFT JOIN Sources ON Images.SourceID = Sources.SourceID ORDER BY ImageName LIMIT $start,$numrows" );
Best, beth
|
|---|