2009-08-21 7 views
1

私はSQLに慣れています。なぜすべてのアイデア基本的なSQLのもの...左への参加

SELECT media.id as mediaid, media.title as mediatitle, 
    media.description as mediadescription, media.date as mediadate, 
    media.duration, media.price as mediaprice, media.thumburl as thumburl 
FROM `media` 
WHERE media.title = 'Code of Ethical Conduct' 

....これは

SELECT media.id as mediaid, media.title as mediatitle, 
    media.description as mediadescription, media.date as mediadate, 
    media.duration, media.price as mediaprice, media.thumburl as thumburl, 
    presenters.f_name as firstname, presenters.l_name as lastname, 
    presenters.credentials 
FROM `media` 
WHERE media.title = 'Code of Ethical Conduct' 
LEFT JOIN `presenters` ON presenters.fkMediaID = media.id 

.....結果を返しませんでした。しかし、私はプレゼンターの一部を追加する前に、それがうまく働いていましたか?句は、最後

を行くので、それはメディア左からだろう

答えて

9

ザ・プレゼンターを登録しよう..... media.title ....

3

LEFTは、一部のJOIN

する必要がありますの前にWHERE部分。

SELECT media.id as mediaid, media.title as mediatitle, 
    media.description as mediadescription, media.date as mediadate, 
    media.duration, media.price as mediaprice, media.thumburl as thumburl, 
    presenters.f_name as firstname, presenters.l_name as lastname, 
    presenters.credentials 
FROM media 
LEFT JOIN presenters ON presenters.fkMediaID = media.id 
WHERE media.title = 'Code of Ethical Conduct' 
+0

少し早く:) – voyager