开发者

Error with my left joins?

I'm thinking the coffee isn't strong enough today. I need to query the table fb-celebotd to get the photoid that matches the fb-celebotd.celebdate. Most of the other info needed is dependent on the p开发者_运维问答hotos table.

The following is giving me a mysql error:

Select photos.*,photographer.name, events.eventname, events.eventhome, subevents.subeventname, photodir.photodir, fb-celebotd.celebdate, fb-celebotd.trivia 
      from photos 
LEFT JOIN fb-celebotd ON (photos.photoid = fb-celebotd.photoid) 
LEFT JOIN photodir ON (photos.photodirid = photodir.photodirid) 
LEFT JOIN photographer ON (photos.photographerid = photographer.photographerid) 
LEFT JOIN events ON (photos.eventid = events.eventid) 
LEFT JOIN subevents ON (photos.subeventid = subevents.subeventid) 
WHERE fb-celebotd.celebdate=1277092800

Is this doable in one query or do I have to query fb-celebotd for the photoid and trivia first and then query other tables based on the photoid?

Thanks.


Should fb-celebotd (with a dash) be fb_celebotd (with an underscore)? If the table name has a dash, then you'll have to quote the table name: "fb-celebotd". Otherwise the dash is treated as a minus sign and tries to subtract celebotd from fb (both unknown).


If you really have a table named fb-celebotd, then you need to quote the table name every time you use it in a query:

Select photos.*,photographer.name, events.eventname, events.eventhome, subevents.subeventname, photodir.photodir, `fb-celebotd`.celebdate, `fb-celebotd`.trivia 
      from photos 
LEFT JOIN `fb-celebotd` ON (photos.photoid = `fb-celebotd`.photoid) 
LEFT JOIN photodir ON (photos.photodirid = photodir.photodirid) 
LEFT JOIN photographer ON (photos.photographerid = photographer.photographerid) 
LEFT JOIN events ON (photos.eventid = events.eventid) 
LEFT JOIN subevents ON (photos.subeventid = subevents.subeventid) 
WHERE `fb-celebotd`.celebdate=1277092800
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜